public ActionResult Submit(int id, string IndexType, string TransactionType) { #region DocTypeTimeLineValidation DispatchWaybillHeader s = db.DispatchWaybillHeader.Find(id); try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Submit, User.Identity.Name, out ExceptionMsg, out Continue); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation && !Continue) { return(RedirectToAction("Index", new { id = s.DocTypeId, IndexType = IndexType })); } #endregion return(RedirectToAction("Detail", new { id = id, IndexType = IndexType, transactionType = string.IsNullOrEmpty(TransactionType) ? "submit" : TransactionType })); }
private ActionResult Edit(int id, string IndexType) { ViewBag.IndexStatus = IndexType; DispatchWaybillHeader s = _DispatchWaybillHeaderService.Find(id); if (s == null) { return(HttpNotFound()); } #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 DispatchWaybillHeaderViewModel svm = new DispatchWaybillHeaderViewModel(); svm = Mapper.Map <DispatchWaybillHeader, DispatchWaybillHeaderViewModel>(s); if ((!TimePlanValidation && !Continue)) { return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType })); } PrepareViewBag(svm); PrepareViewBag(s.DocTypeId); ViewBag.Mode = "Edit"; if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create")) { LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = s.DocTypeId, DocId = s.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Detail, DocNo = s.DocNo, DocDate = s.DocDate, DocStatus = s.Status, })); } return(View("Create", svm)); }
public ActionResult DeleteAfter_Submit(int id) { DispatchWaybillHeader DispatchWaybillHeader = _DispatchWaybillHeaderService.Find(id); if (DispatchWaybillHeader.Status == (int)StatusConstants.Submitted || DispatchWaybillHeader.Status == (int)StatusConstants.Modified) { return(Remove(id)); } else { return(HttpNotFound()); } }
public ActionResult Delete(int id) { DispatchWaybillHeader DispatchWaybillHeader = _DispatchWaybillHeaderService.Find(id); if (DispatchWaybillHeader.Status == (int)StatusConstants.Drafted || DispatchWaybillHeader.Status == (int)StatusConstants.Import) { return(Remove(id)); } else { return(HttpNotFound()); } }
public ActionResult ModifyAfter_Submit(int id, string IndexType) { DispatchWaybillHeader header = _DispatchWaybillHeaderService.Find(id); if (header.Status == (int)StatusConstants.Submitted || header.Status == (int)StatusConstants.Modified || header.Status == (int)StatusConstants.ModificationSubmitted) { return(Edit(id, IndexType)); } else { return(HttpNotFound()); } }
// GET: /PurchaseOrderHeader/Delete/5 private ActionResult Remove(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DispatchWaybillHeader DispatchWaybillHeader = _DispatchWaybillHeaderService.Find(id); if (DispatchWaybillHeader == null) { return(HttpNotFound()); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(DispatchWaybillHeader), DocumentTimePlanTypeConstants.Delete, User.Identity.Name, out ExceptionMsg, out Continue); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation && !Continue) { return(PartialView("AjaxError")); } #endregion ReasonViewModel rvm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", rvm)); }
public void Update(DispatchWaybillHeader s) { s.ObjectState = ObjectState.Modified; _unitOfWork.Repository <DispatchWaybillHeader>().Update(s); }
public void Delete(DispatchWaybillHeader s) { _unitOfWork.Repository <DispatchWaybillHeader>().Delete(s); }
public DispatchWaybillHeader Create(DispatchWaybillHeader s) { s.ObjectState = ObjectState.Added; _unitOfWork.Repository <DispatchWaybillHeader>().Insert(s); return(s); }
public ActionResult Create(DispatchWaybillHeaderViewModel svm) { string DataValidationMsg = DataValidation(svm); if (DataValidationMsg != "") { PrepareViewBag(svm); PrepareViewBag(svm.DocTypeId); return(View(svm).Danger(DataValidationMsg)); } #region DocTypeTimeLineValidation try { if (svm.DispatchWaybillHeaderId <= 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 && (TimePlanValidation || Continue)) { #region CreateRecord if (svm.DispatchWaybillHeaderId == 0) { DispatchWaybillHeader DispatchWaybillHeader = Mapper.Map <DispatchWaybillHeaderViewModel, DispatchWaybillHeader>(svm); DispatchWaybillHeader.CreatedDate = DateTime.Now; DispatchWaybillHeader.ModifiedDate = DateTime.Now; DispatchWaybillHeader.CreatedBy = User.Identity.Name; DispatchWaybillHeader.ModifiedBy = User.Identity.Name; DispatchWaybillHeader.Status = (int)StatusConstants.Drafted; if (svm.DocTypeId == new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.PreDispatchWaybill).DocumentTypeId) { DispatchWaybillHeader.IsPreCarriage = true; } else { DispatchWaybillHeader.IsPreCarriage = false; } _DispatchWaybillHeaderService.Create(DispatchWaybillHeader); var routecities = new RouteLineService(_unitOfWork).GetRouteLineListForIndex(svm.RouteId).ToList(); foreach (var item in routecities) { DispatchWaybillLine DispatchWaybillLine = new DispatchWaybillLine(); DispatchWaybillLine.CityId = item.CityId; DispatchWaybillLine.CreatedDate = DateTime.Now; DispatchWaybillLine.ModifiedDate = DateTime.Now; DispatchWaybillLine.CreatedBy = User.Identity.Name; DispatchWaybillLine.ModifiedBy = User.Identity.Name; new DispatchWaybillLineService(_unitOfWork).Create(DispatchWaybillLine); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm); ViewBag.Mode = "Add"; return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = DispatchWaybillHeader.DocTypeId, DocId = DispatchWaybillHeader.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Added, DocNo = DispatchWaybillHeader.DocNo, DocDate = DispatchWaybillHeader.DocDate, DocStatus = DispatchWaybillHeader.Status, })); return(RedirectToAction("Modify", new { id = DispatchWaybillHeader.DispatchWaybillHeaderId }).Success("Data saved Successfully")); } #endregion #region EditRecord else { int routeid = _DispatchWaybillHeaderService.GetDispatchWaybillHeaderViewModel(svm.DispatchWaybillHeaderId).RouteId; DispatchWaybillHeader DispatchWaybillHeader = Mapper.Map <DispatchWaybillHeaderViewModel, DispatchWaybillHeader>(svm); int status = DispatchWaybillHeader.Status; if (DispatchWaybillHeader.Status != (int)StatusConstants.Drafted && DispatchWaybillHeader.Status != (int)StatusConstants.Import) { DispatchWaybillHeader.Status = (int)StatusConstants.Modified; } DispatchWaybillHeader.Status = (int)StatusConstants.Modified; DispatchWaybillHeader.ModifiedDate = DateTime.Now; DispatchWaybillHeader.ModifiedBy = User.Identity.Name; _DispatchWaybillHeaderService.Update(DispatchWaybillHeader); if (routeid != svm.RouteId) { var dispatchwaybillline = new DispatchWaybillLineService(_unitOfWork).GetDispatchWaybillLineForHeaderId(svm.DispatchWaybillHeaderId); foreach (var item in dispatchwaybillline) { new DispatchWaybillLineService(_unitOfWork).Delete(item.DispatchWaybillLineId); } var routecities = new RouteLineService(_unitOfWork).GetRouteLineListForIndex(svm.RouteId).ToList(); foreach (var item in routecities) { DispatchWaybillLine DispatchWaybillLine = new DispatchWaybillLine(); DispatchWaybillLine.DispatchWaybillHeaderId = DispatchWaybillHeader.DispatchWaybillHeaderId; DispatchWaybillLine.CityId = item.CityId; DispatchWaybillLine.CreatedDate = DateTime.Now; DispatchWaybillLine.ModifiedDate = DateTime.Now; DispatchWaybillLine.CreatedBy = User.Identity.Name; DispatchWaybillLine.ModifiedBy = User.Identity.Name; new DispatchWaybillLineService(_unitOfWork).Create(DispatchWaybillLine); } } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; ViewBag.Mode = "Edit"; return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = DispatchWaybillHeader.DocTypeId, DocId = DispatchWaybillHeader.DispatchWaybillHeaderId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = DispatchWaybillHeader.DocNo, DocDate = DispatchWaybillHeader.DocDate, DocStatus = DispatchWaybillHeader.Status, })); return(RedirectToAction("Index", new { id = svm.DocTypeId, IndexType = "" }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm); PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }