public ActionResult Edit(int?id) { var model = new FirstNoticeOfLossEditViewModel(); if (id != null && id != 0) { var data = _fis.GetById(Convert.ToInt32(id)); model = Mapper.Map <first_notice_of_loss, FirstNoticeOfLossEditViewModel>(data); //for filling the dropdown lists for existent banks model.ClaimantBankAccounts = _bas.BankAccountsByInsuredId(model.ClaimantId); model.PolicyHolderBankAccounts = _bas.BankAccountsByInsuredId(model.PolicyHolderId); //documents and invoices model.Invoices = new List <FileDescriptionViewModel>(); model.InsuranceInfoDoc = new List <FileDescriptionViewModel>(); model = GetAllDocuments(model); } return(View(model)); }
public static void UpdateAdditionalInfo(FirstNoticeOfLossEditViewModel model, IFirstNoticeOfLossService _fnol, IAdditionalInfoService _ais, ILuggageInsuranceService _lis, IHealthInsuranceService _his) { var fnol = _fnol.GetById(model.Id); var additionalInfo = fnol.additional_info; if (fnol.additional_info.health_insurance_info != null) { var healthInfo = fnol.additional_info.health_insurance_info; additionalInfo.Accident_place = model.AccidentPlaceHealth; additionalInfo.Datetime_accident = model.AccidentDateTimeHealth ?? new DateTime(0, 0, 0); additionalInfo.Datetime_accident.Add(model.AccidentTimeHealth ?? new TimeSpan(0, 0, 0)); healthInfo.Datetime_doctor_visit = model.DoctorVisitDateTime; healthInfo.Doctor_info = model.DoctorInfo; healthInfo.Medical_case_description = model.MedicalCaseDescription; healthInfo.Previous_medical_history = model.PreviousMedicalHistory; healthInfo.Responsible_institution = model.ResponsibleInstitution; _ais.UpdateAdditionalAndHealthInfo(additionalInfo, healthInfo); } else { var luggageInfo = fnol.additional_info.luggage_insurance_info; additionalInfo.Accident_place = model.AccidentPlaceLuggage; additionalInfo.Datetime_accident = model.AccidentDateTimeLuggage ?? new DateTime(0, 0, 0); //additionalInfo.Datetime_accident.Add(model.AccidentTimeLuggage ?? new TimeSpan(0, 0, 0)); var a = additionalInfo.Datetime_accident.Date + model.AccidentTimeLuggage; additionalInfo.Datetime_accident = a ?? new DateTime(0, 0, 0); luggageInfo.Place_description = model.PlaceDescription; luggageInfo.Detail_description = model.DetailDescription; luggageInfo.Report_place = model.ReportPlace; luggageInfo.Floaters = model.Floaters; luggageInfo.Floaters_value = Int64.Parse(model.FloatersValue); luggageInfo.Luggage_checking_Time = model.LugaggeCheckingTime ?? new TimeSpan(0, 0, 0); _ais.UpdateAdditionalAndLuggageInfo(additionalInfo, luggageInfo); } }
public static void UpdateFirstNoticeOfLoss(FirstNoticeOfLossEditViewModel model, IFirstNoticeOfLossService _fnol, IBankAccountService _bas, IAdditionalInfoService _ais, IHealthInsuranceService _his, ILuggageInsuranceService _lis, IFirstNoticeOfLossArchiveService _firstNoticeLossArchive, IEnumerable <HttpPostedFileBase> invoices, IEnumerable <HttpPostedFileBase> documentsHealth, IEnumerable <HttpPostedFileBase> documentsLuggage) { var fnol = _fnol.GetById(model.Id); //bank accounts update var isArchived = ArchiveFirstNoticeOfLossHelper.ArchiveFirstNoticeOfLoss(fnol, model.ModifiedBy, _fnol, _firstNoticeLossArchive); if (!fnol.Claimant_bank_account_info.Account_Number.ToString().Equals(model.ClaimantBankAccountNumber) || !fnol.Claimant_bank_account_info.bank.Name.Equals(model.ClaimantBankName)) { var bankAccountId = UpdateBankAccountInfoHelper.UpdateBankAccountInfo(fnol.Claimant_bank_accountID, model.ClaimantBankAccountNumber.Trim(), model.ClaimantBankName, fnol.ClaimantId, _bas); _fnol.UpdateClaimantBankAccountId(fnol.ID, bankAccountId); } if (!fnol.Policy_holder_bank_account_info.Account_Number.ToString().Equals(model.PolicyHolderBankAccountNumber) || !fnol.Policy_holder_bank_account_info.bank.Name.Equals(model.PolicyHolderBankName)) { var bankAccountId = UpdateBankAccountInfoHelper.UpdateBankAccountInfo(fnol.Policy_holder_bank_accountID, model.PolicyHolderBankAccountNumber.Trim(), model.PolicyHolderBankName, fnol.travel_policy.Policy_HolderID, _bas); _fnol.UpdatePolicyHolderBankAccountId(fnol.ID, bankAccountId); } UpdateAdditionalInfoHelper.UpdateAdditionalInfo(model, _fnol, _ais, _lis, _his); //jos vkupna vrednost i dokumenti var newFnol = fnol; newFnol.Modified_Datetime = DateTime.Now; newFnol.ModifiedBy = model.ModifiedBy; newFnol.Destination = model.Destination; newFnol.Depart_Date_Time = model.DepartDateTime.Date; newFnol.Depart_Date_Time = model.DepartDateTime.Date + (model.DepartTime ?? new TimeSpan(0, 0, 0)); //newFnol.Depart_Date_Time = new DateTime(model.DepartDateTime.Year,); newFnol.Arrival_Date_Time = model.ArrivalDateTime.Date; newFnol.Arrival_Date_Time = model.ArrivalDateTime.Date + (model.ArriveTime ?? new TimeSpan(0, 0, 0)); newFnol.Transport_means = model.TransportMeans; newFnol.Relation_claimant_policy_holder = model.RelationClaimantPolicyHolder; newFnol.Total_cost = model.TotalCost; _fnol.Update(newFnol); if (invoices != null) { foreach (var file in invoices) { if (file != null && file.ContentLength > 0) { var path = @"~/DocumentsFirstNoticeOfLoss/Invoices/" + file.FileName; file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path)); var document = new document(); document.Name = file.FileName; var documentID = _fnol.AddDocument(document); _fnol.AddInvoice(documentID); _fnol.AddDocumentToFirstNoticeOfLoss(documentID, fnol.ID); } } } if (documentsHealth != null) { foreach (var file in documentsHealth) { if (file != null && file.ContentLength > 0) { var path = @"~/DocumentsFirstNoticeOfLoss/HealthInsurance/" + file.FileName; file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path)); var document = new document(); document.Name = file.FileName; var documentID = _fnol.AddDocument(document); _fnol.AddDocumentToFirstNoticeOfLoss(documentID, fnol.ID); } } } if (documentsLuggage != null) { foreach (var file in documentsLuggage) { if (file != null && file.ContentLength > 0) { var path = @"~/DocumentsFirstNoticeOfLoss/LuggageInsurance/" + file.FileName; file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path)); var document = new document(); document.Name = file.FileName; var documentID = _fnol.AddDocument(document); _fnol.AddDocumentToFirstNoticeOfLoss(documentID, fnol.ID); } } } }