コード例 #1
0
        public ActionResult DeleteConfirmed(long id)
        {
            OutboundShipmentsPost outboundshipments = _outboundshipmentsService.GetPost(id);

            outboundshipments.UserName = User.Identity.Name;
            _outboundshipmentsService.Delete(outboundshipments);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Edit([Bind("ixOutboundShipment,sOutboundShipment,ixFacility,ixCompany,ixCarrier,sCarrierConsignmentNumber,ixStatus,ixAddress,ixOutboundCarrierManifest")] OutboundShipmentsPost outboundshipments)
        {
            if (ModelState.IsValid)
            {
                outboundshipments.UserName = User.Identity.Name;
                _outboundshipmentsService.Edit(outboundshipments);
                return(RedirectToAction("Index"));
            }
            ViewBag.ixAddress  = new SelectList(_outboundshipmentsService.selectAddresses().Select(x => new { x.ixAddress, x.sAddress }), "ixAddress", "sAddress", outboundshipments.ixAddress);
            ViewBag.ixCarrier  = new SelectList(_outboundshipmentsService.selectCarriers().Select(x => new { x.ixCarrier, x.sCarrier }), "ixCarrier", "sCarrier", outboundshipments.ixCarrier);
            ViewBag.ixCompany  = new SelectList(_outboundshipmentsService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany", outboundshipments.ixCompany);
            ViewBag.ixFacility = new SelectList(_outboundshipmentsService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", outboundshipments.ixFacility);
            ViewBag.ixOutboundCarrierManifest = new SelectList(_outboundshipmentsService.selectOutboundCarrierManifestsNullable().Select(x => new { ixOutboundCarrierManifest = x.Key, sOutboundCarrierManifest = x.Value }), "ixOutboundCarrierManifest", "sOutboundCarrierManifest", outboundshipments.ixOutboundCarrierManifest);
            ViewBag.ixStatus = new SelectList(_outboundshipmentsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", outboundshipments.ixStatus);

            return(View(outboundshipments));
        }
コード例 #3
0
        public ActionResult Edit(long id)
        {
            OutboundShipmentsPost outboundshipments = _outboundshipmentsService.GetPost(id);

            if (outboundshipments == null)
            {
                return(NotFound());
            }
            ViewBag.ixAddress  = new SelectList(_outboundshipmentsService.selectAddresses().Select(x => new { x.ixAddress, x.sAddress }), "ixAddress", "sAddress", outboundshipments.ixAddress);
            ViewBag.ixCarrier  = new SelectList(_outboundshipmentsService.selectCarriers().Select(x => new { x.ixCarrier, x.sCarrier }), "ixCarrier", "sCarrier", outboundshipments.ixCarrier);
            ViewBag.ixCompany  = new SelectList(_outboundshipmentsService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany", outboundshipments.ixCompany);
            ViewBag.ixFacility = new SelectList(_outboundshipmentsService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", outboundshipments.ixFacility);
            ViewBag.ixOutboundCarrierManifest = new SelectList(_outboundshipmentsService.selectOutboundCarrierManifestsNullable().Select(x => new { ixOutboundCarrierManifest = x.Key, sOutboundCarrierManifest = x.Value }), "ixOutboundCarrierManifest", "sOutboundCarrierManifest", outboundshipments.ixOutboundCarrierManifest);
            ViewBag.ixStatus = new SelectList(_outboundshipmentsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", outboundshipments.ixStatus);

            return(View(outboundshipments));
        }
コード例 #4
0
        public Task Delete(OutboundShipmentsPost outboundshipmentsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._outboundshipmentsRepository.RegisterDelete(outboundshipmentsPost);
            try
            {
                this._outboundshipmentsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._outboundshipmentsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.CompletedTask);
        }
コード例 #5
0
        public Task <Int64> Create(OutboundShipmentsPost outboundshipmentsPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._outboundshipmentsRepository.RegisterCreate(outboundshipmentsPost);
            try
            {
                this._outboundshipmentsRepository.Commit();
            }
            catch (Exception ex)
            {
                this._outboundshipmentsRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process

            return(Task.FromResult(outboundshipmentsPost.ixOutboundShipment));
        }
コード例 #6
0
 public void RegisterDelete(OutboundShipmentsPost outboundshipmentsPost)
 {
     _context.OutboundShipmentsPost.Remove(outboundshipmentsPost);
 }
コード例 #7
0
 public void RegisterEdit(OutboundShipmentsPost outboundshipmentsPost)
 {
     _context.Entry(outboundshipmentsPost).State = EntityState.Modified;
 }
コード例 #8
0
 public void RegisterCreate(OutboundShipmentsPost outboundshipmentsPost)
 {
     _context.OutboundShipmentsPost.Add(outboundshipmentsPost);
 }
コード例 #9
0
        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));
        }