public async Task <ActionResult> Edit(Guid id, CaseAidViewModel caseAidViewModel) { try { if (ModelState.IsValid) { caseAidViewModel.AidId = id; var result = await _caseService.UpdateCaseAid(caseAidViewModel); if (result.Succeeded) { return(RedirectToAction("Index", new { CaseId = caseAidViewModel.CaseId })); } } } catch (Exception ex) { Logger.Error(ex); } var currentCase = await _caseService.GetCase(caseAidViewModel.CaseId); caseAidViewModel.Case = currentCase; return(View(caseAidViewModel)); }
public async Task <EntityResult> DeleteCaseAid(CaseAidViewModel caseAidViewModel) { try { Guard.ArgumentIsNull <ArgumentNullException>(caseAidViewModel , nameof(caseAidViewModel)); var currentCase = await _caseUnitOfWork.CaseRepository .GetCaseWithAids(caseAidViewModel.CaseId); if (currentCase == null) { throw new ArgumentException(CasesResource.CaseIsNotExist , nameof(caseAidViewModel)); } currentCase.DeleteAid(caseAidViewModel.AidId); await _caseUnitOfWork.SaveAsync(); return(EntityResult.Success); } catch (Exception ex) { _logger.Error(ex); throw; } }
public async Task <EntityResult> UpdateCaseAid(CaseAidViewModel caseAidViewModel) { try { Guard.ArgumentIsNull <ArgumentNullException>(caseAidViewModel , nameof(caseAidViewModel)); var currentCase = await _caseUnitOfWork.CaseRepository .GetCaseWithAids(caseAidViewModel.CaseId); if (currentCase == null) { throw new ArgumentException(CasesResource.CaseIsNotExist , nameof(caseAidViewModel)); } currentCase.UpdateAid( caseAidViewModel.AidId , (Sanable.Cases.Domain.Model.AidTypes)caseAidViewModel.AidType , caseAidViewModel.Description , caseAidViewModel.AidDate , caseAidViewModel.Amount , caseAidViewModel.Notes , _userFactory.CurrentUserName); await _caseUnitOfWork.SaveAsync(); return(EntityResult.Success); } catch (Exception ex) { _logger.Error(ex); throw; } }
public async Task <ActionResult> Edit(Guid id) { CaseAidViewModel caseAid = await _caseService.GetCaseAidById(id); if (caseAid == null) { AddMessageToTempData(CasesResource.ItemIsNotExist, BusinessSolutions.MVCCommon.MessageType.Error); return(RedirectToAction("Index", "Management", new { area = "Cases", caseType = CaseStatus.Approved })); } return(View(caseAid)); }