Example #1
0
        public async Task <IActionResult> BrandAddPopup(DiscountModel.AddBrandToDiscountModel model)
        {
            var discount = await _discountService.GetDiscountById(model.DiscountId);

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

            if (model.SelectedBrandIds != null)
            {
                await _discountViewModelService.InsertBrandToDiscountModel(model);
            }
            ViewBag.RefreshPage = true;
            return(View(model));
        }
Example #2
0
        public virtual async Task InsertBrandToDiscountModel(DiscountModel.AddBrandToDiscountModel model)
        {
            foreach (string id in model.SelectedBrandIds)
            {
                var brand = await _brandService.GetBrandById(id);

                if (brand != null)
                {
                    if (brand.AppliedDiscounts.Count(d => d == model.DiscountId) == 0)
                    {
                        brand.AppliedDiscounts.Add(model.DiscountId);
                    }

                    await _brandService.UpdateBrand(brand);
                }
            }
        }
Example #3
0
        public async Task <IActionResult> BrandAddPopupList(DataSourceRequest command, DiscountModel.AddBrandToDiscountModel model, [FromServices] IBrandService brandService)
        {
            var brands = await brandService.GetAllBrands(model.SearchBrandName, _workContext.CurrentCustomer.StaffStoreId, command.Page - 1, command.PageSize, true);

            var gridModel = new DataSourceResult
            {
                Data  = brands.Select(x => x.ToModel()),
                Total = brands.TotalCount
            };

            return(Json(gridModel));
        }
Example #4
0
        public IActionResult BrandAddPopup(string discountId)
        {
            var model = new DiscountModel.AddBrandToDiscountModel();

            return(View(model));
        }