Exemplo n.º 1
0
        public void UpdateCartonRequest(PullRequest model, RequestProperties propertiesToUpdate)
        {
            var modelToUpdate = _repos.GetRequests(model.CtnResvId, 1).SingleOrDefault();

            if (modelToUpdate == null)
            {
                throw new ProviderException("Invalid Request Id passed");
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.AllowOverPulling))
            {
                modelToUpdate.AllowOverPulling = model.AllowOverPulling;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.BuildingId))
            {
                modelToUpdate.BuildingId = model.BuildingId;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.CartonReceivedDate))
            {
                modelToUpdate.CartonReceivedDate = model.CartonReceivedDate;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.DestinationArea))
            {
                modelToUpdate.DestinationArea = model.DestinationArea;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.PriceSeasonCode))
            {
                modelToUpdate.PriceSeasonCode = model.PriceSeasonCode;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.Priority))
            {
                modelToUpdate.Priority = model.Priority;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.QualityCode))
            {
                modelToUpdate.SourceQuality = model.SourceQuality;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.Remarks))
            {
                modelToUpdate.Remarks = model.Remarks;
            }

            if (propertiesToUpdate.HasFlag(RequestProperties.SewingPlantCode))
            {
                modelToUpdate.SewingPlantCode = model.SewingPlantCode;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.SourceAreaId))
            {
                modelToUpdate.SourceAreaId = model.SourceAreaId;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.SourceVwhId))
            {
                modelToUpdate.SourceVwhId = model.SourceVwhId;
            }
            if (propertiesToUpdate.HasFlag(RequestProperties.TargetVwhId))
            {
                modelToUpdate.TargetVwhId = model.TargetVwhId;
            }

            if (propertiesToUpdate.HasFlag(RequestProperties.TargetQualityCode))
            {
                modelToUpdate.TargetQuality = model.TargetQuality;
            }
            CreateCartonRequest(modelToUpdate);
        }
Exemplo n.º 2
0
        public virtual ActionResult UpdateRequest(PropertyEditorViewModel model)
        {
            var rvm = new PropertyEditorViewModel();

            if (!ModelState.IsValid)
            {
                // Unable to Create or Update Populate RequestViewModel again
                rvm.ResvId = model.ResvId;
                PopulateIndexViewModel(rvm);
                return(View(Views.PropertyEditor, rvm));

                throw new NotImplementedException();
            }
            var requestModel = new PullRequest
            {
                AllowOverPulling         = model.OverPullCarton ? "O" : "U",
                BuildingId               = model.BuildingId,
                CtnResvId                = model.ResvId,
                DestinationArea          = model.DestinationAreaId,
                Priority                 = model.Priorities.ToString(),
                Remarks                  = model.Remarks,
                SourceAreaId             = model.SourceAreaId,
                TargetVwhId              = model.TargetVwhId,
                SourceVwhId              = model.VirtualWareHouseId,
                IsConversionRequest      = model.RequestForConversion,
                SourceQuality            = model.SourceQualityCode,
                TargetQuality            = model.TargetQualityCode,
                DestinationAreaShortName = model.DestinationAreaShortName,
                //ReqId = model.CurrentRequest.ReqId,
                RequestedBy         = model.RequestedBy,
                SourceAreaShortName = model.SourceAreaShortName
            };

            if (string.IsNullOrEmpty(model.ResvId))
            {
                //Creating New Request
                try
                {
                    _service.CreateCartonRequest(requestModel);
                }
                catch (ProviderException ex)
                {
                    PopulateIndexViewModel(rvm);
                    ModelState.AddModelError("", ex.Message);
                    return(View(Views.PropertyEditor, rvm));
                }
            }
            else
            {
                try
                {
                    //updating existing Request
                    _service.UpdateCartonRequest(requestModel, RequestProperties.BuildingId | RequestProperties.SourceAreaId | RequestProperties.Priority |
                                                 RequestProperties.TargetVwhId | RequestProperties.DestinationArea | RequestProperties.AllowOverPulling | RequestProperties.PackagingPreference |
                                                 RequestProperties.SaleTypeId | RequestProperties.SourceVwhId | RequestProperties.Remarks | RequestProperties.QualityCode | RequestProperties.TargetQualityCode);
                }
                catch (ProviderException ex)
                {
                    PopulateIndexViewModel(rvm);
                    rvm.ResvId = requestModel.CtnResvId;
                    ModelState.AddModelError("", ex.Message);
                    return(View(Views.PropertyEditor, rvm));
                }
            }
            var cookie = new HttpCookie(COOKIE_BUILDING)
            {
                Value   = requestModel.BuildingId,
                Expires = DateTime.Now.AddDays(7)
            };

            // Remember building for 7 days
            this.Response.Cookies.Add(cookie);
            return(RedirectToAction(MVC_REQ2.REQ2.Home.Actions.PullRequest(requestModel.CtnResvId)));
        }