public void SaveDecision(AppDecisionDTO model) { var decision = _dataService.GetEntity <AppDecision>(p => p.Id == model.Id).SingleOrDefault(); var isUpdate = false; if (decision == null) { decision = new AppDecision(); } else { _dataService.GetEntity <AppDecisionReason>(p => p.AppDecisionId == decision.Id).ToList() .ForEach(x => _dataService.Remove(x)); isUpdate = true; } _objectMapper.Map(model, decision); foreach (var reason in model.ListOfDecisionReason) { decision.AppDecisionReasons.Add(new AppDecisionReason { ReasonType = reason, AppDecisionId = decision.Id }); } var prl = _dataService.GetEntity <PrlApplication>(p => p.Id == decision.AppId).SingleOrDefault(); if (prl == null || string.IsNullOrEmpty(prl.ExpertiseResult) || prl.AppState == "Reviewed") { return; } prl.AppDecision = decision; _dataService.Add(decision, isUpdate); _limsExchangeService.ExportDecision(decision, isUpdate); _dataService.SaveChanges(); }