private void PrepareViewBag(JobOrderLineViewModel vm) { ViewBag.DeliveryUnitList = _JobOrderLineService.GetUnitList(); if (vm != null) { JobOrderHeaderViewModel H = _jobOrderHeaderService.GetJobOrderHeader(vm.JobOrderHeaderId); ViewBag.DocNo = H.DocTypeName + "-" + H.DocNo; } }
// GET: /JobOrderHeader/Edit/5 private ActionResult Edit(int id, string IndexType) { ViewBag.IndexStatus = IndexType; JobOrderHeaderViewModel s = _JobOrderHeaderService.GetJobOrderHeader(id); #region DocTypeTimeLineValidation try { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if ((!TimePlanValidation && !Continue)) { return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType })); } //Job Order Settings var settings = _jobOrderSettingsServie.GetJobOrderSettingsForDocument(s.DocTypeId, s.DivisionId, s.SiteId); if (settings == null && UserRoles.Contains("Admin")) { return(RedirectToAction("Create", "JobOrderSettings", new { id = s.DocTypeId }).Warning("Please create job order settings")); } else if (settings == null && !UserRoles.Contains("Admin")) { return(View("~/Views/Shared/InValidSettings.cshtml")); } s.JobOrderSettings = Mapper.Map <JobOrderSettings, JobOrderSettingsViewModel>(settings); ////Perks s.PerkViewModel = _perkService.GetPerkListForDocumentTypeForEdit(id).ToList(); if (s.PerkViewModel.Count == 0) { List <PerkViewModel> Perks = new List <PerkViewModel>(); if (s.JobOrderSettings.Perks != null) { foreach (var item in s.JobOrderSettings.Perks.Split(',').ToList()) { PerkViewModel temp = Mapper.Map <Perk, PerkViewModel>(_perkService.Find(Convert.ToInt32(item))); var DocTypePerk = _perkDocumentTypeService.GetPerkDocumentTypeForPerk(s.DocTypeId, temp.PerkId, s.SiteId, s.DivisionId); if (DocTypePerk != null) { temp.Base = DocTypePerk.Base; temp.Worth = DocTypePerk.Worth; temp.CostConversionMultiplier = DocTypePerk.CostConversionMultiplier; temp.IsEditableRate = DocTypePerk.IsEditableRate; } else { temp.Base = 0; temp.Worth = 0; temp.CostConversionMultiplier = 0; temp.IsEditableRate = true; } Perks.Add(temp); } } s.PerkViewModel = Perks; } PrepareViewBag(s.DocTypeId); if (s == null) { return(HttpNotFound()); } ViewBag.Mode = "Edit"; ViewBag.transactionType = ""; ViewBag.Name = _documentTypeService.Find(s.DocTypeId).DocumentTypeName; ViewBag.id = s.DocTypeId; if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create")) { _JobOrderHeaderService.LogDetailInfo(s); } return(View("Create", s)); }