Пример #1
0
 public ReceivingProcessModel(ReceivingProcess entity)
 {
     ProDate            = entity.ProDate;
     ProNumber          = entity.ProNumber;
     CarrierId          = entity.CarrierId;
     CarrierDescription = entity.CarrierName;
     OperatorName       = entity.OperatorName;
     ReceivingStartDate = entity.StartDate;
     ReceivingEndDate   = entity.ReceivingEndDate;
     CartonCount        = entity.CartonCount;
     PalletCount        = entity.PalletCount;
     //ReceivingAreaId = src.ReceivingAreaId,
     ProcessId       = entity.ProcessId;
     ExpectedCartons = entity.ExpectedCartons;
 }
Пример #2
0
        public virtual ActionResult CreateUpdateProcess(ProcessEditorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                PopulateIndexViewModel(model);
                return(View(Views.ProcessEditor, model));
            }


            var carrier = _service.Value.GetCarrier(model.CarrierId);


            if (carrier == null)
            {
                ModelState.AddModelError("", string.Format("{0} is invalid Carrier", model.CarrierId));
                PopulateIndexViewModel(model);
                return(View(Views.ProcessEditor, model));
            }


            var processModel = new ReceivingProcess
            {
                ProDate         = model.ProDate,
                ProNumber       = model.ProNumber,
                CarrierId       = model.CarrierId,
                ReceivingAreaId = model.ReceivingAreaId,
                SpotCheckAreaId = model.SpotCheckAreaId,
                PalletLimit     = model.PalletLimit,
                //CartonCount = model.CartonCount,
                ExpectedCartons = model.ExpectedCartons ?? 0,
                PalletCount     = model.PalletCount,
                ProcessId       = model.ProcessId ?? 0,
                PriceSeasonCode = model.PriceSeasonCode
            };

            var cookie = new HttpCookie(COOKIE_ALERT);

            if (model.ProcessId == null)
            {
                //Creating New Process
                try
                {
                    _service.Value.InsertProcess(processModel);

                    //Adding the values to cookie

                    if (!string.IsNullOrEmpty(model.ReceivingAreaId) ||
                        !string.IsNullOrEmpty(model.SpotCheckAreaId) || !string.IsNullOrEmpty(model.PriceSeasonCode) || model.PalletLimit != null)
                    {
                        cookie.Values.Add(COOKIE_ALERT_RECEIVING_AREA, model.ReceivingAreaId);
                        cookie.Values.Add(COOKIE_ALERT_SPOT_CHECK_AREA, model.SpotCheckAreaId);
                        cookie.Values.Add(KEY_PRICE_SEASON_CODE, model.PriceSeasonCode);
                        cookie.Values.Add(KEY_PALLET_LIMIT, model.PalletLimit.ToString());
                        cookie.Expires = DateTime.Now.AddDays(15);
                        this.HttpContext.Response.Cookies.Add(cookie);
                    }
                }
                catch (ProviderException ex)
                {
                    // Exception happened but we still need to populate all the area lists.
                    PopulateIndexViewModel(model);
                    ModelState.AddModelError("", ex.Message);
                    return(View(Views.ProcessEditor, model));
                }
            }
            else
            {
                //updating existing Process
                try
                {
                    _service.Value.UpdateProcess(processModel);
                }
                catch (ProviderException ex)
                {
                    // Exception happened but we still need to populate all the area lists.
                    PopulateIndexViewModel(model);
                    ModelState.AddModelError("", ex.Message);
                    return(View(Views.ProcessEditor, model));
                }
            }


            return(RedirectToAction(MVC_Receiving.Receiving.Home.Receiving(processModel.ProcessId)));
        }