public ActionResult Post(RecipeHeaderViewModel svm) { bool BeforeSave = true; #region DocTypeTimeLineValidation try { if (svm.JobOrderHeaderId <= 0) { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), 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 (svm.MachineId == null) { TempData["CSEXC"] += "Machine is recquired."; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } if (ModelState.IsValid && BeforeSave && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.JobOrderHeaderId <= 0) { try { _RecipeHeaderService.Create(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } return(RedirectToAction("Modify", "RecipeHeader", new { Id = svm.JobOrderHeaderId }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { try { _RecipeHeaderService.Update(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }
public ActionResult Post(DyeingViewModel svm) { bool BeforeSave = true; #region DocTypeTimeLineValidation try { if (svm.JobReceiveHeaderId <= 0) { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), 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 (svm.CompletedDateTime != null) { if (svm.StartDateTime > svm.CompletedDateTime) { TempData["CSEXC"] += "Start date time can't be greater then completed date time."; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } if (svm.StartDateTimeHour > 24 || svm.CompletedDateTimeHour > 24) { TempData["CSEXC"] += "Hour value can not be greater then 24."; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } if (svm.StartDateTimeMinute > 59 || svm.CompletedDateTimeMinute > 59) { TempData["CSEXC"] += "Minute value can not be greater then 59."; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } } if (svm.MachineId == null) { TempData["CSEXC"] += "Machine is recquired."; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } if (ModelState.IsValid && BeforeSave && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.JobReceiveHeaderId <= 0) { try { _DyeingService.Create(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } return(RedirectToAction("Create", "Dyeing", new { Id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { try { _DyeingService.Update(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }
public ActionResult Post(PropertyHeaderViewModel svm) { bool BeforeSave = true; int SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; svm.Code = _PropertyHeaderService.FGetNewPersonCode(SiteId, svm.GodownId, svm.BinLocationId); svm.Suffix = svm.Code; #region DocTypeTimeLineValidation try { if (svm.PersonID <= 0) { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), 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 (ModelState.IsValid && BeforeSave && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.PersonID <= 0) { try { _PropertyHeaderService.Create(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } return(RedirectToAction("Modify", "PropertyHeader", new { Id = svm.PersonID }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { try { _PropertyHeaderService.Update(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }
public ActionResult Post(CollectionViewModel svm) { bool BeforeSave = true; var settings = _CollectionSettingsService.GetCollectionSettingsForDocument(svm.DocTypeId); if (settings != null) { if (settings.IsVisibleReason == true && (svm.ReferenceLedgerAccountId == null || svm.ReferenceLedgerAccountId == 0)) { ModelState.AddModelError("ReferenceLedgerAccountId", "Reason field is required"); } } #region DocTypeTimeLineValidation try { if (svm.LedgerHeaderId <= 0) { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), 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 (ModelState.IsValid && BeforeSave && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.LedgerHeaderId <= 0) { try { _CollectionService.Create(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } return(RedirectToAction("Modify", "Collection", new { Id = svm.LedgerHeaderId }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { try { _CollectionService.Update(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } return(RedirectToAction("Index", new { id = svm.DocTypeId, PersonId = svm.PersonId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }
public ActionResult Post(JobOrderHeaderViewModel svm) { bool BeforeSave = true; var settings = _jobOrderSettingsServie.GetJobOrderSettingsForDocument(svm.DocTypeId, svm.DivisionId, svm.SiteId); if (settings != null) { if (svm.JobOrderSettings.isMandatoryCostCenter == true && (string.IsNullOrEmpty(svm.CostCenterName))) { ModelState.AddModelError("CostCenterName", "The CostCenter field is required"); } if (svm.JobOrderSettings.isMandatoryMachine == true && (svm.MachineId <= 0 || svm.MachineId == null)) { ModelState.AddModelError("MachineId", "The Machine field is required"); } if (svm.JobOrderSettings.isVisibleGodown == true && svm.JobOrderSettings.isMandatoryGodown == true && !svm.GodownId.HasValue) { ModelState.AddModelError("GodownId", "The Godown field is required"); } if (settings.MaxDays.HasValue && (svm.DueDate - svm.DocDate).Days > settings.MaxDays.Value) { ModelState.AddModelError("DueDate", "DueDate is exceeding MaxDueDays."); } } if (!string.IsNullOrEmpty(svm.CostCenterName)) { string CostCenterValidation = _JobOrderHeaderService.ValidateCostCenter(svm.DocTypeId, svm.JobOrderHeaderId, svm.JobWorkerId, svm.CostCenterName); if (!string.IsNullOrEmpty(CostCenterValidation)) { ModelState.AddModelError("CostCenterName", CostCenterValidation); } } #region DocTypeTimeLineValidation try { if (svm.JobOrderHeaderId <= 0) { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = _documentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), 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 (ModelState.IsValid && BeforeSave && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.JobOrderHeaderId <= 0) { try { _JobOrderHeaderService.Create(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } return(RedirectToAction("Modify", "JobOrderHeader", new { Id = svm.JobOrderHeaderId }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { try { _JobOrderHeaderService.Update(svm, User.Identity.Name); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }