コード例 #1
0
        public ActionResult DeleteConfirmed(long id)
        {
            PickBatchesPost pickbatches = _pickbatchesService.GetPost(id);

            pickbatches.UserName = User.Identity.Name;
            _pickbatchesService.Delete(pickbatches);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Edit([Bind("ixPickBatch,sPickBatch,ixPickBatchType,bMultiResource,dtStartBy,dtCompleteBy,ixStatus")] PickBatchesPost pickbatches)
        {
            if (ModelState.IsValid)
            {
                pickbatches.UserName = User.Identity.Name;
                _pickbatchesService.Edit(pickbatches);
                return(RedirectToAction("Index"));
            }
            ViewBag.ixPickBatchType = new SelectList(_pickbatchesService.selectPickBatchTypes().Select(x => new { x.ixPickBatchType, x.sPickBatchType }), "ixPickBatchType", "sPickBatchType", pickbatches.ixPickBatchType);
            ViewBag.ixStatus        = new SelectList(_pickbatchesService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", pickbatches.ixStatus);

            return(View(pickbatches));
        }
コード例 #3
0
        public ActionResult Edit(long id)
        {
            PickBatchesPost pickbatches = _pickbatchesService.GetPost(id);

            if (pickbatches == null)
            {
                return(NotFound());
            }
            ViewBag.ixPickBatchType = new SelectList(_pickbatchesService.selectPickBatchTypes().Select(x => new { x.ixPickBatchType, x.sPickBatchType }), "ixPickBatchType", "sPickBatchType", pickbatches.ixPickBatchType);
            ViewBag.ixStatus        = new SelectList(_pickbatchesService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", pickbatches.ixStatus);

            return(View(pickbatches));
        }
コード例 #4
0
        public Task <Int64> Create(PickBatchesPost pickbatchesPost)
        {
            // Additional validations

            // Pre-process

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

            // Post-process

            return(Task.FromResult(pickbatchesPost.ixPickBatch));
        }
コード例 #5
0
        public Task Delete(PickBatchesPost pickbatchesPost)
        {
            // Additional validations

            // Pre-process

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

            // Post-process

            return(Task.CompletedTask);
        }
コード例 #6
0
        public Task Edit(PickBatchesPost pickbatchesPost)
        {
            // Additional validations

            // Pre-process

            // Process
            this._pickbatchesRepository.RegisterEdit(pickbatchesPost);
            try
            {
                this._pickbatchesRepository.Commit();
            }
            catch (Exception ex)
            {
                this._pickbatchesRepository.Rollback();
                // Log exception
                throw;
            }

            // Post-process
            //Custom Code Start | Added Code Block

            if (pickbatchesPost.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault())
            {
                // We check if the shipment associated with the orders on the batch has been manifested. If not we try and find an active manifest else we create a new one and add the shipment to it
                var outboundShipments = _outboundordersRepository.IndexDb().Where(x => x.ixPickBatch == pickbatchesPost.ixPickBatch).Select(x => x.ixOutboundShipment).ToList();
                var outboundShipmentsNotManifested = _outboundshipmentsService.IndexDb().Where(x => x.ixOutboundCarrierManifest == null)
                                                     .Join(outboundShipments, os => os.ixOutboundShipment, o => o, (os, o) => new { Os = os, O = o })
                                                     .Select(s => s.Os.ixOutboundShipment).ToList();

                outboundShipmentsNotManifested.ForEach(x =>
                {
                    var outboundShipment = _outboundshipmentsService.GetPost(x);
                    if (
                        _outboundcarriermanifestsService.IndexDb().Where(m =>
                                                                         m.ixFacility == outboundShipment.ixFacility &&
                                                                         m.ixCarrier == outboundShipment.ixCarrier &&
                                                                         m.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault()
                                                                         ).Any())
                    {
                        var ixOutboundCarrierManifest = _outboundcarriermanifestsService.IndexDb().Where(m =>
                                                                                                         m.ixFacility == outboundShipment.ixFacility &&
                                                                                                         m.ixCarrier == outboundShipment.ixCarrier &&
                                                                                                         m.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault()
                                                                                                         ).Select(m => m.ixOutboundCarrierManifest).FirstOrDefault();
                        outboundShipment.ixOutboundCarrierManifest = ixOutboundCarrierManifest;
                        outboundShipment.UserName = pickbatchesPost.UserName;
                        _outboundshipmentsService.Edit(outboundShipment);
                    }
                    else
                    {
                        OutboundCarrierManifestsPost outboundCarrierManifestsPost = new OutboundCarrierManifestsPost();
                        outboundCarrierManifestsPost.ixFacility = outboundShipment.ixFacility;
                        outboundCarrierManifestsPost.ixCarrier  = outboundShipment.ixCarrier;
                        outboundCarrierManifestsPost.ixPickupInventoryLocation = _shipping.getTrailerDoorSuggestion(outboundShipment.ixFacility);
                        outboundCarrierManifestsPost.ixStatus            = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
                        outboundCarrierManifestsPost.dtScheduledPickupAt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) + _outboundshipmentsService.CarriersDb().Where(c => c.ixCarrier == outboundShipment.ixCarrier).Select(c => c.dtScheduledPickupTime).FirstOrDefault();
                        outboundCarrierManifestsPost.UserName            = pickbatchesPost.UserName;
                        var ixOutboundCarrierManifest = _outboundcarriermanifestsService.Create(outboundCarrierManifestsPost).Result;
                        outboundShipment.ixOutboundCarrierManifest = ixOutboundCarrierManifest;
                        outboundShipment.UserName = pickbatchesPost.UserName;
                        _outboundshipmentsService.Edit(outboundShipment);
                    }
                }
                                                       );
            }
            //Custom Code End



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