Пример #1
0
 public virtual ActionResult AssignCartons2(string ctnresvId)
 {
     if (string.IsNullOrEmpty(ctnresvId))
     {
         throw new ApplicationException("Internal Error. Request Id was not passed.");
     }
     try
     {
         _service.AssignCartons(ctnresvId);
     }
     catch (DbException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     //Following PRG model
     return(RedirectToAction(MVC_REQ2.REQ2.Home.PullRequest(ctnresvId)));
 }
Пример #2
0
        public virtual ActionResult AssignCartons()
        {
            var ctnresvId = this.ValueProvider.GetValue(EclipseLibrary.Mvc.Helpers.ReflectionHelpers.NameFor((ManageSkuViewModel m) => m.ResvId))
                            .AttemptedValue;

            if (string.IsNullOrEmpty(ctnresvId))
            {
                throw new ApplicationException("Internal Error. Request Id was not passed.");
            }
            var         rules = new RequestCartonRulesViewModel();
            PullRequest requestUpdated;

            if (TryUpdateModel(rules, EclipseLibrary.Mvc.Helpers.ReflectionHelpers.NameFor((ManageSkuViewModel m) => m.CartonRules)))
            {
                try
                {
                    //If already cartons assigned to request, Firstly we have to unassign this
                    // Unassign carton is intelligent enough to not do anything if cartons have not been assigned
                    _service.UnAssignCartons(ctnresvId);
                    requestUpdated = new PullRequest
                    {
                        SourceQuality      = rules.QualityCode,
                        SewingPlantCode    = rules.SewingPlantCode,
                        PriceSeasonCode    = rules.PriceSeasonCode,
                        CartonReceivedDate = rules.CartonReceivedDate,
                        BuildingId         = rules.BuildingId
                    };
                    requestUpdated.CtnResvId = ctnresvId;
                    //Trying to update the carton rules of request
                    _service.UpdateCartonRequest(requestUpdated, RequestProperties.CartonReceivedDate | RequestProperties.BuildingId | RequestProperties.QualityCode |
                                                 RequestProperties.SewingPlantCode | RequestProperties.PriceSeasonCode);
                    //Assigning cartons to the request
                    _service.AssignCartons(ctnresvId);
                }
                catch (DbException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch (ProviderException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }

            requestUpdated = _service.GetRequestInfo(ctnresvId);
            return(DoDisplayRequest(requestUpdated, ModelState.IsValid ? ViewTab.CartonList : ViewTab.AssignCartons));
        }