コード例 #1
0
        public virtual ActionResult EnableVasConfiguration(EnableVasConfigurationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(Actions.CustomerVas(model.CustomerId, model.VasId)));
            }
            var message = string.Format("VAS Configuration of customer: <em>{0}</em> is enabled for ", model.CustomerId);

            switch (model.OrderType)
            {
            case OrderType.AllOrders:
                _service.EnableVasConfiguration(model.CustomerId, model.VasId, model.PatternRegEx, true);
                message += "<em>all orders.</em>";
                break;

            case OrderType.AllExcludingCurrentOrders:
                _service.EnableVasConfiguration(model.CustomerId, model.VasId, model.PatternRegEx, false);
                message += "<em>all orders except current orders.</em>";
                break;

            default:
                throw new NotImplementedException();
            }
            AddStatusMessage(message);
            return(RedirectToAction(Actions.CustomerVas(model.CustomerId, model.VasId)));
        }
コード例 #2
0
        public virtual ActionResult EnableVasConfiguration(string customerId, string vasId)
        {
            var customerVasList = _service.GetCustomerVasSettings(customerId).ToArray();

            if (customerVasList.All(p => p.VasId != vasId))
            {
                ModelState.AddModelError("", string.Format("VAS setting for customer {0} is already removed.", customerId));
                return(RedirectToAction(Actions.Index()));
            }
            var customerVasSetting = customerVasList.First(p => p.VasId == vasId);

            var model = new EnableVasConfigurationViewModel
            {
                CustomerId            = customerId,
                CustomerName          = customerVasSetting.CustomerName,
                VasId                 = vasId,
                VasDescription        = customerVasSetting.VasDescription,
                UserRemarks           = customerVasSetting.Remark,
                VasPatternDescription = customerVasSetting.VasPatternDescription,
                InactiveFlag          = customerVasSetting.InactiveFlag,
                PatternRegEx          = customerVasSetting.PatternRegEx,
                ListBeingApplied      = _service.GetQualifyingCustomerPos(customerId, vasId, customerVasSetting.PatternRegEx).ToArray()
            };

            return(View(Views.EnableVasConfiguration, model));
        }