public ActionResult _Create(int Id, bool?IsSaleBased) //Id ==>Sale Order Header Id { SaleDeliveryHeader H = new SaleDeliveryHeaderService(_unitOfWork).Find(Id); SaleDeliveryLineViewModel s = new SaleDeliveryLineViewModel(); //Getting Settings var settings = new SaleDeliverySettingService(_unitOfWork).GetSaleDeliverySettingForDocument(H.DocTypeId, H.DivisionId, H.SiteId); s.SaleDeliverySettings = Mapper.Map <SaleDeliverySetting, SaleDeliverySettingsViewModel>(settings); s.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId); s.SaleDeliveryHeaderId = H.SaleDeliveryHeaderId; s.SaleDeliveryHeaderDocNo = H.DocNo; s.DocTypeId = H.DocTypeId; s.SiteId = H.SiteId; s.DivisionId = H.DivisionId; ViewBag.LineMode = "Create"; PrepareViewBag(); if (IsSaleBased == true) { return(PartialView("_CreateForSaleOrder", s)); } else { return(PartialView("_Create", s)); } }
private ActionResult _Modify(int id) { SaleDeliveryLine temp = _SaleDeliveryLineService.Find(id); if (temp == null) { return(HttpNotFound()); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocumentLine(new DocumentUniqueId { LockReason = temp.LockReason }, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXCL"] += ExceptionMsg; } #endregion if ((TimePlanValidation || Continue)) { ViewBag.LineMode = "Edit"; } SaleDeliveryHeader H = new SaleDeliveryHeaderService(_unitOfWork).Find(temp.SaleDeliveryHeaderId); PrepareViewBag(); SaleDeliveryLineViewModel vm = _SaleDeliveryLineService.GetSaleDeliveryLineForEdit(id); //Getting Settings var settings = new SaleDeliverySettingService(_unitOfWork).GetSaleDeliverySettingForDocument(H.DocTypeId, H.DivisionId, H.SiteId); vm.SaleDeliverySettings = Mapper.Map <SaleDeliverySetting, SaleDeliverySettingsViewModel>(settings); vm.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId); vm.SiteId = H.SiteId; vm.DivisionId = H.DivisionId; vm.DocTypeId = H.DocTypeId; return(PartialView("_Create", vm)); }
public ActionResult _Detail(int id) { SaleDeliveryLine temp = _SaleDeliveryLineService.Find(id); SaleDeliveryHeader H = new SaleDeliveryHeaderService(_unitOfWork).Find(temp.SaleDeliveryHeaderId); PrepareViewBag(); SaleDeliveryLineViewModel vm = _SaleDeliveryLineService.GetSaleDeliveryLineForEdit(id); //Getting Settings var settings = new SaleDeliverySettingService(_unitOfWork).GetSaleDeliverySettingForDocument(H.DocTypeId, H.DivisionId, H.SiteId); vm.SaleDeliverySettings = Mapper.Map <SaleDeliverySetting, SaleDeliverySettingsViewModel>(settings); if (temp == null) { return(HttpNotFound()); } return(PartialView("_Create", vm)); }
public ActionResult DeletePost(SaleDeliveryLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); int?StockId = 0; SaleDeliveryHeader Dh = new SaleDeliveryHeaderService(_unitOfWork).Find(vm.SaleDeliveryHeaderId); int status = Dh.Status; SaleDeliveryLine Dl = _SaleDeliveryLineService.Find(vm.SaleDeliveryLineId); LogList.Add(new LogTypeViewModel { ExObj = Dl, }); _SaleDeliveryLineService.Delete(Dl); if (Dh.Status != (int)StatusConstants.Drafted) { Dh.Status = (int)StatusConstants.Modified; new SaleDeliveryHeaderService(_unitOfWork).Update(Dh); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(); return(PartialView("_Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Dh.DocTypeId, DocId = Dh.SaleDeliveryHeaderId, DocLineId = Dl.SaleDeliveryLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = Dh.DocNo, xEModifications = Modifications, DocDate = Dh.DocDate, DocStatus = Dh.Status, })); return(Json(new { success = true })); }
//[ValidateAntiForgeryToken] public ActionResult _CreatePost(SaleDeliveryLineViewModel svm) { SaleDeliverySetting Settings = new SaleDeliverySettingService(_unitOfWork).GetSaleDeliverySettingForDocument(svm.DocTypeId, svm.DivisionId, svm.SiteId); SaleDeliveryHeader Dh = new SaleDeliveryHeaderService(_unitOfWork).Find(svm.SaleDeliveryHeaderId); if (svm.SaleDeliveryLineId <= 0) { ViewBag.LineMode = "Create"; } else { ViewBag.LineMode = "Edit"; } if (svm.SaleInvoiceLineId <= 0) { ModelState.AddModelError("SaleInvoiceLineId", "Sale Invoice field is required"); } if (svm.Qty <= 0) { ModelState.AddModelError("Qty", "The Qty field is required"); } if (ModelState.IsValid) { if (svm.SaleDeliveryLineId <= 0) { SaleDeliveryLine Dl = Mapper.Map <SaleDeliveryLineViewModel, SaleDeliveryLine>(svm); Dl.SaleDeliveryHeaderId = Dh.SaleDeliveryHeaderId; Dl.CreatedBy = User.Identity.Name; Dl.CreatedDate = DateTime.Now; Dl.ModifiedBy = User.Identity.Name; Dl.ModifiedDate = DateTime.Now; Dl.ObjectState = Model.ObjectState.Added; _SaleDeliveryLineService.Create(Dl); if (Dh.Status != (int)StatusConstants.Drafted) { Dh.Status = (int)StatusConstants.Modified; } new SaleDeliveryHeaderService(_unitOfWork).Update(Dh); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(); return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Dh.DocTypeId, DocId = Dl.SaleDeliveryHeaderId, DocLineId = Dl.SaleDeliveryLineId, ActivityType = (int)ActivityTypeContants.Added, DocNo = Dh.DocNo, DocDate = Dh.DocDate, DocStatus = Dh.Status, })); return(RedirectToAction("_Create", new { id = Dh.SaleDeliveryHeaderId })); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); int status = Dh.Status; SaleDeliveryLine Dl = _SaleDeliveryLineService.Find(svm.SaleDeliveryLineId); SaleDeliveryLine ExRecD = new SaleDeliveryLine(); ExRecD = Mapper.Map <SaleDeliveryLine>(Dl); Dl.SaleInvoiceLineId = svm.SaleInvoiceLineId; Dl.Qty = svm.Qty; Dl.DealQty = svm.DealQty; Dl.DealUnitId = svm.DealUnitId; Dl.Remark = svm.Remark; _SaleDeliveryLineService.Update(Dl); LogList.Add(new LogTypeViewModel { ExObj = ExRecD, Obj = Dl, }); if (Dh.Status != (int)StatusConstants.Drafted) { Dh.Status = (int)StatusConstants.Modified; new SaleDeliveryHeaderService(_unitOfWork).Update(Dh); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(); return(PartialView("_Create", svm)); } //Saving the Activity Log LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Dh.DocTypeId, DocId = Dl.SaleDeliveryHeaderId, DocLineId = Dl.SaleDeliveryLineId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = Dh.DocNo, xEModifications = Modifications, DocDate = Dh.DocDate, DocStatus = Dh.Status, })); //End of Saving the Activity Log return(Json(new { success = true })); } } PrepareViewBag(); return(PartialView("_Create", svm)); }