Example #1
0
 public void AddCorrectiveActionFromAction(CorrectiveActionDataModel model, int userId, int LoggedInUserId, int LoggedInOrganizationId)
 {
     if (model.CorrectiveActionId == 0)
     {
         var data = Mapper.Map <CorrectiveActionDataModel, CorrectiveAction>(model);
         data.AcitonId       = model.ActionID;
         data.OrganizationID = LoggedInOrganizationId;
         Add(data, LoggedInUserId, LoggedInOrganizationId);
         model.CorrectiveActionId = data.CorrectiveActionId;
     }
     else
     {
         var data = Mapper.Map <CorrectiveActionDataModel, CorrectiveAction>(model);
         if (model.ActionID > 0)
         {
             data.AcitonId = model.ActionID;
         }
         model.CorrectiveActionId = data.CorrectiveActionId;
         //data.DateResolved = DateTime.Now;
         Update(data);
     }
     base.RepositoryContext.SP_DeleteCorrectiveList(model.CorrectiveActionId, LoggedInOrganizationId);
     if (model.ActionResponsiblePersonDataModel != null && model.ActionResponsiblePersonDataModel.Any())
     {
         foreach (var childModel in model.ActionResponsiblePersonDataModel)
         {
             if (childModel == null || childModel.UserID == 0)
             {
                 continue;
             }
             CorrectiveActionAssignedToList child = new CorrectiveActionAssignedToList();
             child.CorrectiveActionId = model.CorrectiveActionId;
             child.UserId             = childModel.UserID;
             child.OrganizationId     = LoggedInOrganizationId;
             this._ICorrectiveActionAssignedToListRepository.Add(child, LoggedInUserId, LoggedInOrganizationId);
         }
     }
     if (model.ResultList != null && model.ResultList.Any())
     {
         foreach (string result in model.ResultList)
         {
             base.RepositoryContext.SP_AddCorrectiveActionResult(userId, model.CorrectiveActionId, result, LoggedInOrganizationId);
         }
     }
 }
 public void Update(CorrectiveActionAssignedToList entity, int LoggedInUserId, int LoggedInOrganizationId)
 {
     base.Update(entity);
     _unitOfWork.Save();
 }