BUG

parent 2b09ff8d
......@@ -8,6 +8,7 @@ namespace Performance.DtoModels
{
public class SetAssessRequest
{
public int AllotID { get; set; }
public int AssessID { get; set; }
public List<string> Department { get; set; }
}
......@@ -16,6 +17,7 @@ public class SetAssessRequestValidator : AbstractValidator<SetAssessRequest>
{
public SetAssessRequestValidator()
{
RuleFor(t => t.AllotID).NotNull().GreaterThan(0);
RuleFor(t => t.AssessID).NotNull().GreaterThan(0);
RuleFor(t => t.Department).NotNull().Must(p =>
{
......
......@@ -22,6 +22,11 @@ public class as_data
public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 考核类别ID
/// </summary>
public Nullable<int> AssessID { get; set; }
......
......@@ -94,11 +94,20 @@ public ApiResponse SetAssessType(SetAssessRequest request)
if (entity == null)
return new ApiResponse(ResponseType.Fail, "考核类别ID无效");
var entities = perforAsdataRepository.GetEntities(t => t.AssessID == request.AssessID && request.Department.Contains(t.Department));
if (entities != null && entities.Count > 0)
return new ApiResponse(ResponseType.Fail, "科室考核类别重复分配", entities.Select(t => t.Department));
var addList = request.Department.Select(t => new as_data { AssessID = request.AssessID, Department = t }).ToArray();
var entities = perforAsdataRepository.GetEntities(t => t.AllotID == request.AllotID);
if (entities != null)
{
//保留共有
var intersectList = entities.Where(t => t.AssessID == request.AssessID).Select(t => t.Department).Intersect(request.Department).ToList();
if (intersectList != null && intersectList.Count() > 0)
intersectList.ForEach(t => request.Department.Remove(t));
//删除更改
var removeList = perforAsdataRepository.GetEntities(t => intersectList.Contains(t.Department));
if (removeList != null && removeList.Count() > 0)
perforAsdataRepository.RemoveRange(removeList.ToArray());
}
//添加新增
var addList = request.Department.Select(t => new as_data { AllotID = request.AllotID, AssessID = request.AssessID, Department = t }).ToArray();
var result = perforAsdataRepository.AddRange(addList);
return result ? new ApiResponse(ResponseType.OK) : new ApiResponse(ResponseType.Fail);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment