public ActionResult Create([Bind("ixOutboundOrder,sOutboundOrder,sOrderReference,ixOutboundOrderType,ixFacility,ixCompany,ixBusinessPartner,dtDeliverEarliest,dtDeliverLatest,ixCarrierService,ixStatus,ixPickBatch,ixOutboundShipment")] OutboundOrdersPost outboundorders) { if (ModelState.IsValid) { outboundorders.UserName = User.Identity.Name; //Custom Code Start | Replaced Code Block //Replaced Code Block Start //_outboundordersService.Create(outboundorders); //return RedirectToAction("Index"); //Replaced Code Block End var ixOutboundOrder = _outboundordersService.Create(outboundorders).Result; return(RedirectToAction("Edit", new { id = ixOutboundOrder })); //Custom Code End } ViewBag.ixBusinessPartner = new SelectList(_outboundordersService.selectBusinessPartners().Select(x => new { x.ixBusinessPartner, x.sBusinessPartner }), "ixBusinessPartner", "sBusinessPartner"); ViewBag.ixCarrierService = new SelectList(_outboundordersService.selectCarrierServices().Select(x => new { x.ixCarrierService, x.sCarrierService }), "ixCarrierService", "sCarrierService"); ViewBag.ixCompany = new SelectList(_outboundordersService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany"); ViewBag.ixFacility = new SelectList(_outboundordersService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility"); ViewBag.ixOutboundOrderType = new SelectList(_outboundordersService.selectOutboundOrderTypes().Select(x => new { x.ixOutboundOrderType, x.sOutboundOrderType }), "ixOutboundOrderType", "sOutboundOrderType"); ViewBag.ixOutboundShipment = new SelectList(_outboundordersService.selectOutboundShipments().Select(x => new { x.ixOutboundShipment, x.sOutboundShipment }), "ixOutboundShipment", "sOutboundShipment"); ViewBag.ixPickBatch = new SelectList(_outboundordersService.selectPickBatches().Select(x => new { x.ixPickBatch, x.sPickBatch }), "ixPickBatch", "sPickBatch"); ViewBag.ixStatus = new SelectList(_outboundordersService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus"); return(View(outboundorders)); }
public ActionResult DeleteConfirmed(long id) { OutboundOrdersPost outboundorders = _outboundordersService.GetPost(id); outboundorders.UserName = User.Identity.Name; _outboundordersService.Delete(outboundorders); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind("ixOutboundOrder,sOutboundOrder,sOrderReference,ixOutboundOrderType,ixFacility,ixCompany,ixBusinessPartner,dtDeliverEarliest,dtDeliverLatest,ixCarrierService,ixStatus,ixPickBatch,ixOutboundShipment")] OutboundOrdersPost outboundorders) { if (ModelState.IsValid) { outboundorders.UserName = User.Identity.Name; _outboundordersService.Edit(outboundorders); return(RedirectToAction("Index")); } ViewBag.ixBusinessPartner = new SelectList(_outboundordersService.selectBusinessPartners().Select(x => new { x.ixBusinessPartner, x.sBusinessPartner }), "ixBusinessPartner", "sBusinessPartner", outboundorders.ixBusinessPartner); ViewBag.ixCarrierService = new SelectList(_outboundordersService.selectCarrierServices().Select(x => new { x.ixCarrierService, x.sCarrierService }), "ixCarrierService", "sCarrierService", outboundorders.ixCarrierService); ViewBag.ixCompany = new SelectList(_outboundordersService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany", outboundorders.ixCompany); ViewBag.ixFacility = new SelectList(_outboundordersService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", outboundorders.ixFacility); ViewBag.ixOutboundOrderType = new SelectList(_outboundordersService.selectOutboundOrderTypes().Select(x => new { x.ixOutboundOrderType, x.sOutboundOrderType }), "ixOutboundOrderType", "sOutboundOrderType", outboundorders.ixOutboundOrderType); ViewBag.ixOutboundShipment = new SelectList(_outboundordersService.selectOutboundShipmentsNullable().Select(x => new { ixOutboundShipment = x.Key, sOutboundShipment = x.Value }), "ixOutboundShipment", "sOutboundShipment", outboundorders.ixOutboundShipment); ViewBag.ixPickBatch = new SelectList(_outboundordersService.selectPickBatchesNullable().Select(x => new { ixPickBatch = x.Key, sPickBatch = x.Value }), "ixPickBatch", "sPickBatch", outboundorders.ixPickBatch); ViewBag.ixStatus = new SelectList(_outboundordersService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", outboundorders.ixStatus); return(View(outboundorders)); }
public ActionResult Edit(long id) { OutboundOrdersPost outboundorders = _outboundordersService.GetPost(id); if (outboundorders == null) { return(NotFound()); } ViewBag.ixBusinessPartner = new SelectList(_outboundordersService.selectBusinessPartners().Select(x => new { x.ixBusinessPartner, x.sBusinessPartner }), "ixBusinessPartner", "sBusinessPartner", outboundorders.ixBusinessPartner); ViewBag.ixCarrierService = new SelectList(_outboundordersService.selectCarrierServices().Select(x => new { x.ixCarrierService, x.sCarrierService }), "ixCarrierService", "sCarrierService", outboundorders.ixCarrierService); ViewBag.ixCompany = new SelectList(_outboundordersService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany", outboundorders.ixCompany); ViewBag.ixFacility = new SelectList(_outboundordersService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", outboundorders.ixFacility); ViewBag.ixOutboundOrderType = new SelectList(_outboundordersService.selectOutboundOrderTypes().Select(x => new { x.ixOutboundOrderType, x.sOutboundOrderType }), "ixOutboundOrderType", "sOutboundOrderType", outboundorders.ixOutboundOrderType); ViewBag.ixOutboundShipment = new SelectList(_outboundordersService.selectOutboundShipmentsNullable().Select(x => new { ixOutboundShipment = x.Key, sOutboundShipment = x.Value }), "ixOutboundShipment", "sOutboundShipment", outboundorders.ixOutboundShipment); ViewBag.ixPickBatch = new SelectList(_outboundordersService.selectPickBatchesNullable().Select(x => new { ixPickBatch = x.Key, sPickBatch = x.Value }), "ixPickBatch", "sPickBatch", outboundorders.ixPickBatch); ViewBag.ixStatus = new SelectList(_outboundordersService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", outboundorders.ixStatus); return(View(outboundorders)); }
public Task Delete(OutboundOrdersPost outboundordersPost) { // Additional validations // Pre-process // Process this._outboundordersRepository.RegisterDelete(outboundordersPost); try { this._outboundordersRepository.Commit(); } catch (Exception ex) { this._outboundordersRepository.Rollback(); // Log exception throw; } // Post-process return(Task.CompletedTask); }
public void RegisterDelete(OutboundOrdersPost outboundordersPost) { _context.OutboundOrdersPost.Remove(outboundordersPost); }
public void RegisterEdit(OutboundOrdersPost outboundordersPost) { _context.Entry(outboundordersPost).State = EntityState.Modified; }
public void RegisterCreate(OutboundOrdersPost outboundordersPost) { _context.OutboundOrdersPost.Add(outboundordersPost); }
public Task <Int64> Create(OutboundOrdersPost outboundordersPost) { // Additional validations // Pre-process //Custom Code Start | Added Code Block //We batch and consign the order //As a simple placeholder we use Discrete order picking - single picker PickBatchesPost pickBatch = new PickBatchesPost(); pickBatch.ixPickBatchType = _pickbatchesService.PickBatchTypesDb().Where(x => x.sPickBatchType == "Discrete order picking - single picker").Select(x => x.ixPickBatchType).FirstOrDefault(); pickBatch.bMultiResource = false; pickBatch.dtStartBy = DateTime.Now; pickBatch.dtCompleteBy = pickBatch.dtStartBy.Add(new TimeSpan(1, 0, 0, 0)); pickBatch.ixStatus = _pickbatchesService.StatusesDb().Where(x => x.sStatus == "Inactive").Select(x => x.ixStatus).FirstOrDefault(); pickBatch.UserName = outboundordersPost.UserName; var ixPickBatch = _pickbatchesService.Create(pickBatch).Result; outboundordersPost.ixPickBatch = ixPickBatch; //We start by trying to find an existing active outboundShipment that matches out order if (_outboundshipmentsService.IndexDb().Where(x => x.ixFacility == outboundordersPost.ixFacility && x.ixCompany == outboundordersPost.ixCompany && x.ixCarrier == _outboundordersRepository.CarrierServicesDb().Where(c => c.ixCarrierService == outboundordersPost.ixCarrierService).Select(c => c.Carriers.ixCarrier).FirstOrDefault() && x.ixAddress == _outboundordersRepository.BusinessPartnersDb().Where(b => b.ixBusinessPartner == outboundordersPost.ixBusinessPartner).Select(b => b.ixAddress).FirstOrDefault() && x.ixStatus == _outboundordersRepository.StatusesDb().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault() ).Select(x => x.ixOutboundShipment).Any()) { var ixOutboundShipment = _outboundshipmentsService.IndexDb().Where(x => x.ixFacility == outboundordersPost.ixFacility && x.ixCompany == outboundordersPost.ixCompany && x.ixCarrier == _outboundordersRepository.CarrierServicesDb().Where(c => c.ixCarrier == outboundordersPost.ixCarrierService).Select(c => c.Carriers.ixCarrier).FirstOrDefault() && x.ixAddress == _outboundordersRepository.BusinessPartnersDb().Where(b => b.ixBusinessPartner == outboundordersPost.ixBusinessPartner).Select(b => b.ixAddress).FirstOrDefault() && x.ixStatus == _outboundordersRepository.StatusesDb().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault() ).Select(x => x.ixOutboundShipment).FirstOrDefault(); outboundordersPost.ixOutboundShipment = ixOutboundShipment; } else { OutboundShipmentsPost outboundShipment = new OutboundShipmentsPost(); outboundShipment.ixFacility = outboundordersPost.ixFacility; outboundShipment.ixCompany = outboundordersPost.ixCompany; outboundShipment.ixCarrier = _outboundordersRepository.CarrierServicesDb().Where(x => x.ixCarrier == outboundordersPost.ixCarrierService).Select(x => x.Carriers.ixCarrier).FirstOrDefault(); var carrier = _carriersService.GetPost(outboundShipment.ixCarrier); if (carrier.nCarrierConsignmentNumberLastUsed == null || carrier.nCarrierConsignmentNumberLastUsed < carrier.nCarrierConsignmentNumberStart) { outboundShipment.sCarrierConsignmentNumber = carrier.sCarrierConsignmentNumberPrefix + carrier.nCarrierConsignmentNumberStart.ToString(); carrier.nCarrierConsignmentNumberLastUsed = carrier.nCarrierConsignmentNumberStart; } else { outboundShipment.sCarrierConsignmentNumber = carrier.sCarrierConsignmentNumberPrefix + (carrier.nCarrierConsignmentNumberLastUsed + 1).ToString(); carrier.nCarrierConsignmentNumberLastUsed += 1; } _carriersService.Edit(carrier); outboundShipment.ixStatus = _outboundordersRepository.StatusesDb().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault(); outboundShipment.ixAddress = _outboundordersRepository.BusinessPartnersDb().Where(b => b.ixBusinessPartner == outboundordersPost.ixBusinessPartner).Select(b => b.ixAddress).FirstOrDefault(); outboundShipment.UserName = outboundordersPost.UserName; var ixOutboundShipment = _outboundshipmentsService.Create(outboundShipment).Result; outboundordersPost.ixOutboundShipment = ixOutboundShipment; } //Custom Code End // Process this._outboundordersRepository.RegisterCreate(outboundordersPost); try { this._outboundordersRepository.Commit(); } catch (Exception ex) { this._outboundordersRepository.Rollback(); // Log exception throw; } // Post-process return(Task.FromResult(outboundordersPost.ixOutboundOrder)); }