Beispiel #1
0
        public ActionResult Create([Bind("ixOutboundCarrierManifest,sOutboundCarrierManifest,ixFacility,ixCarrier,ixPickupInventoryLocation,dtScheduledPickupAt,ixStatus")] OutboundCarrierManifestsPost outboundcarriermanifests)
        {
            if (ModelState.IsValid)
            {
                outboundcarriermanifests.UserName = User.Identity.Name;
                _outboundcarriermanifestsService.Create(outboundcarriermanifests);
                return(RedirectToAction("Index"));
            }
            ViewBag.ixCarrier  = new SelectList(_outboundcarriermanifestsService.selectCarriers().Select(x => new { x.ixCarrier, x.sCarrier }), "ixCarrier", "sCarrier");
            ViewBag.ixFacility = new SelectList(_outboundcarriermanifestsService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility");
            ViewBag.ixPickupInventoryLocation = new SelectList(_outboundcarriermanifestsService.selectInventoryLocations().Select(x => new { x.ixInventoryLocation, x.sInventoryLocation }), "ixInventoryLocation", "sInventoryLocation");
            ViewBag.ixStatus = new SelectList(_outboundcarriermanifestsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus");

            return(View(outboundcarriermanifests));
        }
Beispiel #2
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);
        }