public IActionResult StoreAddPopupList(DataSourceRequest command, DiscountModel.AddStoreToDiscountModel model, [FromServices] IStoreService storeService)
        {
            var stores    = storeService.GetAllStores();
            var gridModel = new DataSourceResult
            {
                Data  = stores.Select(x => x.ToModel()),
                Total = stores.Count
            };

            return(Json(gridModel));
        }
Exemple #2
0
        public ActionResult StoreAddPopup(string discountId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
            {
                return(AccessDeniedView());
            }

            var model = new DiscountModel.AddStoreToDiscountModel();

            return(View(model));
        }
        public virtual void InsertStoreToDiscountModel(DiscountModel.AddStoreToDiscountModel model)
        {
            foreach (string id in model.SelectedStoreIds)
            {
                var store = _storeService.GetStoreById(id);
                if (store != null)
                {
                    if (store.AppliedDiscounts.Count(d => d == model.DiscountId) == 0)
                    {
                        store.AppliedDiscounts.Add(model.DiscountId);
                    }

                    _storeService.UpdateStore(store);
                }
            }
        }
        public IActionResult StoreAddPopup(DiscountModel.AddStoreToDiscountModel model)
        {
            var discount = _discountService.GetDiscountById(model.DiscountId);

            if (discount == null)
            {
                throw new Exception("No discount found with the specified id");
            }

            if (model.SelectedStoreIds != null)
            {
                _discountViewModelService.InsertStoreToDiscountModel(model);
            }
            ViewBag.RefreshPage = true;
            return(View(model));
        }
Exemple #5
0
        public ActionResult StoreAddPopupList(DataSourceRequest command, DiscountModel.AddStoreToDiscountModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
            {
                return(AccessDeniedView());
            }

            var stores    = _storeService.GetAllStores();
            var gridModel = new DataSourceResult
            {
                Data  = stores.Select(x => x.ToModel()),
                Total = stores.Count
            };

            return(Json(gridModel));
        }
Exemple #6
0
        public ActionResult StoreAddPopup(string btnId, string formId, DiscountModel.AddStoreToDiscountModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
            {
                return(AccessDeniedView());
            }

            var discount = _discountService.GetDiscountById(model.DiscountId);

            if (discount == null)
            {
                throw new Exception("No discount found with the specified id");
            }

            if (model.SelectedStoreIds != null)
            {
                foreach (string id in model.SelectedStoreIds)
                {
                    var store = _storeService.GetStoreById(id);
                    if (store != null)
                    {
                        if (store.AppliedDiscounts.Count(d => d.Id == discount.Id) == 0)
                        {
                            store.AppliedDiscounts.Add(discount);
                        }

                        _storeService.UpdateStore(store);
                    }
                }
            }

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View(model));
        }
        public IActionResult StoreAddPopup(string discountId)
        {
            var model = new DiscountModel.AddStoreToDiscountModel();

            return(View(model));
        }