public async Task <ActionResult> Index(FirstNoticeOfLossReportViewModel firstNoticeOfLossViewModel, IEnumerable <HttpPostedFileBase> invoices, IEnumerable <HttpPostedFileBase> documentsHealth, IEnumerable <HttpPostedFileBase> documentsLuggage) { ModelState.Remove("PolicyHolderForeignBankAccountId"); ModelState.Remove("ClaimantForeignBankAccountId"); if (firstNoticeOfLossViewModel.IsHealthInsurance) { ModelState.Remove("AccidentDateTimeLuggage"); ModelState.Remove("Floaters"); ModelState.Remove("FloatersValue"); ModelState.Remove("AccidentPlaceLuggage"); ModelState.Remove("PlaceDescription"); ModelState.Remove("DetailDescription"); ModelState.Remove("ReportPlace"); ModelState.Remove("AccidentTimeLuggage"); ModelState.Remove("LugaggeCheckingTime"); ModelState.Remove("ArriveTime"); ModelState.Remove("Invoices"); ViewBag.insurance = "Health Insurance"; } else { ModelState.Remove("AccidentDateTimeHealth"); ModelState.Remove("AccidentTimeHealth"); ModelState.Remove("AccidentPlaceHealth"); ModelState.Remove("DoctorVisitDateTime"); ModelState.Remove("DoctorInfo"); ModelState.Remove("ArriveTime"); ModelState.Remove("Invoices"); ViewBag.insurance = "Luggage Insurance"; } if (ModelState.IsValid) { var policy = _ps.GetPolicyIdByPolicyNumber(firstNoticeOfLossViewModel.PolicyNumber.ToString()); if (policy == null) { return(View(firstNoticeOfLossViewModel)); } firstNoticeOfLossViewModel.PolicyId = policy.ID; var result = SaveFirstNoticeOfLossHelper.SaveFirstNoticeOfLoss(_iss, _us, _fis, _bas, _pts, _ais, firstNoticeOfLossViewModel, invoices, documentsHealth, documentsLuggage); if (result > 0) { ViewBag.Message = "Successfully reported!"; return(RedirectToAction("View", new { id = result })); } else { ViewBag.Message = "Something went wrong!"; return(View()); } } else { ViewBag.PolicyNumber = firstNoticeOfLossViewModel.PolicyNumber; } return(View(firstNoticeOfLossViewModel)); }
public JObject ReportDetailLoss(DetailFirstNoticeOfLossViewModel addLoss) { if (addLoss == null) { throw new Exception("Internal error: Empty Loss"); } var policy = _ps.GetPolicyIdByPolicyNumber(addLoss.Policy_Number); if (policy == null) { throw new Exception("Policy not found"); } var idFNOL = SaveFirstNoticeOfLossHelper.SaveDetailFirstNoticeOdLoss(addLoss, policy, _fis, _ais, _bas); if (idFNOL != -1) { JObject data = new JObject(); data.Add("Id", idFNOL); return(data); } else { throw new Exception("Internal error: Not saved"); } }