public ActionResult HeaderPost(string Ids) { string[] subStr = Ids.Split(','); for (int i = 0; i < subStr.Length; i++) { int temp = Convert.ToInt32(subStr[i]); GatePassHeader ah = _GatePassService.Find(temp); ah.Status = 1; ah.ObjectState = Model.ObjectState.Modified; db.GatePassHeader.Add(ah); try { db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); } } // return Json(new { success = true }); return(RedirectToAction("Index1", "GatePass")); }
public GatePassHeader Add(GatePassHeader pt) { _GatePassHeaderRepository.Insert(pt); return(pt); }
public void Update(GatePassHeader pt) { pt.ObjectState = ObjectState.Modified; _GatePassHeaderRepository.Update(pt); }
public void Delete(GatePassHeader pt) { _GatePassHeaderRepository.Delete(pt); }
public GatePassHeader Create(GatePassHeader pt) { pt.ObjectState = ObjectState.Added; _GatePassHeaderRepository.Insert(pt); return(pt); }
public ActionResult DeletePost(GatePassLineViewModel vm) { bool BeforeSave = true; try { BeforeSave = GatePassDocEvents.beforeLineDeleteEvent(this, new JobEventArgs(vm.GatePassHeaderId, vm.GatePassLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Validation failed before delete."; } if (BeforeSave && !EventException) { int?StockId = 0; int?StockProcessId = 0; List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); GatePassLine GatePassLine = (from p in db.GatePassLine where p.GatePassLineId == vm.GatePassLineId select p).FirstOrDefault(); GatePassHeader header = (from p in db.GatePassHeader where p.GatePassHeaderId == GatePassLine.GatePassHeaderId select p).FirstOrDefault(); LogList.Add(new LogTypeViewModel { Obj = Mapper.Map <GatePassLine>(GatePassLine), }); //_GatePassLineService.Delete(GatePassLine); GatePassLine.ObjectState = Model.ObjectState.Deleted; db.GatePassLine.Remove(GatePassLine); 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; db.GatePassHeader.Add(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); //try //{ // GatePassDocEvents.onLineDeleteEvent(this, new JobEventArgs(GatePassLine.GatePassHeaderId, GatePassLine.GatePassLineId), ref db); //} //catch (Exception ex) //{ // string message = _exception.HandleException(ex); // TempData["CSEXCL"] += message; // EventException = true; //} try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(vm); ViewBag.LineMode = "Delete"; return(PartialView("_Create", vm)); } try { GatePassDocEvents.afterLineDeleteEvent(this, new JobEventArgs(GatePassLine.GatePassHeaderId, GatePassLine.GatePassLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } //Saving the Activity Log LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.GatePassHeaderId, DocLineId = GatePassLine.GatePassLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); } return(Json(new { success = true })); }
public GatePassHeader Add(GatePassHeader pt) { _unitOfWork.Repository <GatePassHeader>().Insert(pt); return(pt); }
public void Update(GatePassHeader pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <GatePassHeader>().Update(pt); }
public void Delete(GatePassHeader pt) { _unitOfWork.Repository <GatePassHeader>().Delete(pt); }
public GatePassHeader Create(GatePassHeader pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <GatePassHeader>().Insert(pt); return(pt); }
public void Delete(ReasonViewModel vm, string UserName) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); var JobReceiveHeader = Find(vm.id); GatePassHeader GatePassHEader = new GatePassHeader(); int?StockHeaderId = 0; LogList.Add(new LogTypeViewModel { ExObj = Mapper.Map <JobReceiveHeader>(JobReceiveHeader), }); StockHeaderId = JobReceiveHeader.StockHeaderId; //Then find all the Purchase Order Header Line associated with the above ProductType. //var JobReceiveLine = new JobReceiveLineService(_unitOfWork).GetJobReceiveLineforDelete(vm.id); var JobReceiveLine = (_unitOfWork.Repository <JobReceiveLine>().Query().Get().Where(m => m.JobReceiveHeaderId == vm.id)).ToList(); var JOLineIds = JobReceiveLine.Select(m => m.JobReceiveLineId).ToArray(); var JobReceiveLineStatusRecords = _unitOfWork.Repository <JobReceiveLineStatus>().Query().Get().Where(m => JOLineIds.Contains(m.JobReceiveLineId ?? 0)).ToList(); var ProductUids = JobReceiveLine.Select(m => m.ProductUidId).ToArray(); var BarCodeRecords = _unitOfWork.Repository <ProductUid>().Query().Get().Where(m => ProductUids.Contains(m.ProductUIDId)).ToList(); List <int> StockIdList = new List <int>(); List <int> StockProcessIdList = new List <int>(); foreach (var item in JobReceiveLineStatusRecords) { item.ObjectState = Model.ObjectState.Deleted; _unitOfWork.Repository <JobReceiveLineStatus>().Delete(item); } //Mark ObjectState.Delete to all the Purchase Order Lines. foreach (var item in JobReceiveLine) { LogList.Add(new LogTypeViewModel { ExObj = Mapper.Map <JobReceiveLine>(item), }); if (item.StockId != null) { StockIdList.Add((int)item.StockId); } if (item.StockProcessId != null) { StockProcessIdList.Add((int)item.StockProcessId); } item.ObjectState = Model.ObjectState.Deleted; _unitOfWork.Repository <JobReceiveLine>().Delete(item); } _stockService.DeleteStockMultiple(StockIdList); _stockProcessService.DeleteStockProcessDBMultiple(StockProcessIdList); // Now delete the Purhcase Order Header //_JobReceiveHeaderService.Delete(JobReceiveHeader); int ReferenceDocId = JobReceiveHeader.JobReceiveHeaderId; int ReferenceDocTypeId = JobReceiveHeader.DocTypeId; JobReceiveHeader.ObjectState = Model.ObjectState.Deleted; Delete(JobReceiveHeader); if (StockHeaderId != null) { var StockHeader = _unitOfWork.Repository <StockHeader>().Find(StockHeaderId); StockHeader.ObjectState = Model.ObjectState.Deleted; _unitOfWork.Repository <StockHeader>().Delete(StockHeader); } XElement Modifications = _modificationCheck.CheckChanges(LogList); _unitOfWork.Save(); _logger.LogActivityDetail(logVm.Map(new ActiivtyLogViewModel { DocTypeId = JobReceiveHeader.DocTypeId, DocId = JobReceiveHeader.JobReceiveHeaderId, ActivityType = (int)ActivityTypeContants.Deleted, UserRemark = vm.Reason, DocNo = JobReceiveHeader.DocNo, xEModifications = Modifications, DocDate = JobReceiveHeader.DocDate, DocStatus = JobReceiveHeader.Status, })); }