public ActionResult DeletePost(ProdOrderLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProdOrderLine ProdOrderLine = _ProdOrderLineService.Find(vm.ProdOrderLineId); ProdOrderHeader header = new ProdOrderHeaderService(_unitOfWork).Find(ProdOrderLine.ProdOrderHeaderId); int status = header.Status; LogList.Add(new LogTypeViewModel { ExObj = ProdOrderLine, }); new ProdOrderLineStatusService(_unitOfWork).Delete(ProdOrderLine.ProdOrderLineId); _ProdOrderLineService.Delete(vm.ProdOrderLineId); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Modified; header.ModifiedDate = DateTime.Now; header.ModifiedBy = User.Identity.Name; new ProdOrderHeaderService(_unitOfWork).Update(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.ProdOrderHeaderId, DocLineId = ProdOrderLine.ProdOrderLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); return(Json(new { success = true })); }
private ActionResult _Delete(int id) { ProdOrderLineViewModel temp = _ProdOrderLineService.GetProdOrderLine(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 = "Delete"; } ProdOrderHeader H = new ProdOrderHeaderService(_unitOfWork).Find(temp.ProdOrderHeaderId); //Getting Settings var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId); temp.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings); temp.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId); ViewBag.DocNo = H.DocNo; return(PartialView("_Create", temp)); }
public ActionResult _Detail(int id) { ProdOrderLineViewModel temp = _ProdOrderLineService.GetProdOrderLine(id); if (temp == null) { return(HttpNotFound()); } ProdOrderHeader H = new ProdOrderHeaderService(_unitOfWork).Find(temp.ProdOrderHeaderId); //Getting Settings var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId); temp.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings); ViewBag.DocNo = H.DocNo; return(PartialView("_Create", temp)); }
public ActionResult _Create(int Id) //Id ==>Prod Order Header Id { ProdOrderHeader H = new ProdOrderHeaderService(_unitOfWork).Find(Id); ProdOrderLineViewModel s = new ProdOrderLineViewModel(); //Getting Settings var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId); s.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings); s.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId); s.ProdOrderHeaderId = H.ProdOrderHeaderId; ViewBag.DocNo = H.DocNo; ViewBag.Status = H.Status; ViewBag.LineMode = "Create"; return(PartialView("_Create", s)); }
public ActionResult _CreatePost(ProdOrderLineViewModel svm) { ProdOrderLine s = Mapper.Map <ProdOrderLineViewModel, ProdOrderLine>(svm); ProdOrderHeader temp = new ProdOrderHeaderService(_unitOfWork).Find(s.ProdOrderHeaderId); if (svm.Qty <= 0) { ModelState.AddModelError("Qty", "Please Check Qty"); } if (svm.ProdOrderLineId <= 0) { ViewBag.LineMode = "Create"; } else { ViewBag.LineMode = "Edit"; } if (ModelState.IsValid) { if (svm.ProdOrderLineId == 0) { s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; s.Sr = _ProdOrderLineService.GetMaxSr(s.ProdOrderHeaderId); s.ObjectState = Model.ObjectState.Added; _ProdOrderLineService.Create(s); new ProdOrderLineStatusService(_unitOfWork).CreateLineStatus(s.ProdOrderLineId); ProdOrderHeader header = new ProdOrderHeaderService(_unitOfWork).Find(s.ProdOrderHeaderId); if (header.Status != (int)StatusConstants.Drafted) { header.Status = (int)StatusConstants.Modified; header.ModifiedDate = DateTime.Now; header.ModifiedBy = User.Identity.Name; new ProdOrderHeaderService(_unitOfWork).Update(header); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.ProdOrderHeaderId, DocLineId = s.ProdOrderLineId, ActivityType = (int)ActivityTypeContants.Added, DocNo = temp.DocNo, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(RedirectToAction("_Create", new { id = s.ProdOrderHeaderId })); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProdOrderHeader header = new ProdOrderHeaderService(_unitOfWork).Find(svm.ProdOrderHeaderId); StringBuilder logstring = new StringBuilder(); int status = header.Status; ProdOrderLine temp1 = _ProdOrderLineService.Find(svm.ProdOrderLineId); ProdOrderLine ExRec = new ProdOrderLine(); ExRec = Mapper.Map <ProdOrderLine>(temp1); temp1.DueDate = svm.DueDate; temp1.ProductId = svm.ProductId; temp1.Qty = svm.Qty; temp1.Remark = svm.Remark; temp1.ModifiedDate = DateTime.Now; temp1.ModifiedBy = User.Identity.Name; _ProdOrderLineService.Update(temp1); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp1, }); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Modified; header.ModifiedBy = User.Identity.Name; header.ModifiedDate = DateTime.Now; new ProdOrderHeaderService(_unitOfWork).Update(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = s.ProdOrderHeaderId, DocLineId = s.ProdOrderLineId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.DocNo, xEModifications = Modifications, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(Json(new { success = true })); } } ViewBag.Status = temp.Status; return(PartialView("_Create", svm)); }