public IActionResult EditSurveyFile(int ID, string status) { var model = _surveyFileRepository.GetSurveyFile(ID); var statuses = _statusRepository.GetAllStatuses(); SurveyFileViewModel surveyFileVM = new SurveyFileViewModel { ID = model.ID, Index = model.Index, Date = model.Date.ToString("dd-MMM-yyyy"), InsurerID = model.InsurerID, RepairerName = model.RepairerName, RepairerEmail = model.RepairerEmail, Insured = model.Insured, EstimateDate = model.EstimateDate, BillDate = model.BillDate, FollowUpDate = model.Date.ToString("dd-MMM-yyyy"), HasFile = model.HasFile, HasBill = model.HasBill, HasEstimate = model.HasEstimate, StatusID = model.StatusID, VechicleNo = model.VechicleNo, Statuses = statuses.Select(s => new KeyValuePair <int, string>(s.ID, s.Description)).ToList(), }; ViewBag.ActionStatus = status; return(View(surveyFileVM)); }
public IActionResult CreateSurveyFile() { int fileIndex = _surveyFileRepository.GetAllSurveyFile().Where(x => x.SurveyorID == 1).Count() > 0?_surveyFileRepository.GetAllSurveyFile().Where(x => x.SurveyorID == 1).OrderByDescending(x => x.Index).Select(x => x.Index).First():1; var statuses = _statusRepository.GetAllStatuses(); SurveyFileViewModel model = new SurveyFileViewModel { Index = fileIndex + 1, Statuses = statuses.Select(s => new KeyValuePair <int, string>(s.ID, s.Description)).ToList(), }; return(View(model)); }
public IActionResult SaveSurveyFile(SurveyFileViewModel model) { if (ModelState.IsValid) { SurveyFile surveyFile = new SurveyFile { ID = model.ID, SurveyorID = 1, Index = model.Index, Date = model.Date != "" ? DateTime.Parse(model.Date) : DateTime.Now, InsurerID = model.InsurerID, RepairerName = model.RepairerName, RepairerEmail = model.RepairerEmail, Insured = model.Insured, EstimateDate = model.EstimateDate, BillDate = model.BillDate, FollowUpDate = model.Date != "" ? DateTime.Parse(model.Date) : DateTime.Now.AddDays(10), HasFile = model.HasFile, HasBill = model.HasBill, HasEstimate = model.HasEstimate, StatusID = model.StatusID, VechicleNo = model.VechicleNo, }; var result = surveyFile.ID > 0? _surveyFileRepository.Update(surveyFile) : _surveyFileRepository.Add(surveyFile); if (result != null) { return(RedirectToAction("EditSurveyFile", "SurveyFile", new { ID = result.ID, status = "success" })); } else { return(RedirectToAction("EditSurveyFile", "SurveyFile", new { ID = result.ID, status = "fail" })); } } return(View()); }