Esempio n. 1
0
        public ActionResult VendorAddPopup(string discountId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
            {
                return(AccessDeniedView());
            }

            var model = new DiscountModel.AddVendorToDiscountModel();

            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> VendorAddPopup(DiscountModel.AddVendorToDiscountModel model)
        {
            var discount = await _discountService.GetDiscountById(model.DiscountId);

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

            if (model.SelectedVendorIds != null)
            {
                await _discountViewModelService.InsertVendorToDiscountModel(model);
            }
            ViewBag.RefreshPage = true;
            return(View(model));
        }
        public virtual void InsertVendorToDiscountModel(DiscountModel.AddVendorToDiscountModel model)
        {
            foreach (string id in model.SelectedVendorIds)
            {
                var vendor = _vendorService.GetVendorById(id);
                if (vendor != null)
                {
                    if (vendor.AppliedDiscounts.Count(d => d == model.DiscountId) == 0)
                    {
                        vendor.AppliedDiscounts.Add(model.DiscountId);
                    }

                    _vendorService.UpdateVendor(vendor);
                }
            }
        }
        public IActionResult VendorAddPopupList(DataSourceRequest command, DiscountModel.AddVendorToDiscountModel model, [FromServices] IVendorService vendorService)
        {
            var vendors = vendorService.GetAllVendors(model.SearchVendorName, command.Page - 1, command.PageSize, true);

            //search for emails
            if (!(string.IsNullOrEmpty(model.SearchVendorEmail)))
            {
                var tempVendors = vendors.Where(x => x.Email.ToLowerInvariant().Contains(model.SearchVendorEmail.Trim()));
                vendors = new PagedList <Core.Domain.Vendors.Vendor>(tempVendors, command.Page - 1, command.PageSize);
            }

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

            return(Json(gridModel));
        }
Esempio n. 5
0
        public ActionResult VendorAddPopup(string btnId, string formId, DiscountModel.AddVendorToDiscountModel 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.SelectedVendorIds != null)
            {
                foreach (string id in model.SelectedVendorIds)
                {
                    var vendor = _vendorService.GetVendorById(id);
                    if (vendor != null)
                    {
                        if (vendor.AppliedDiscounts.Count(d => d.Id == discount.Id) == 0)
                        {
                            vendor.AppliedDiscounts.Add(discount);
                        }

                        _vendorService.UpdateVendor(vendor);
                    }
                }
            }

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View(model));
        }
Esempio n. 6
0
        public ActionResult VendorAddPopupList(DataSourceRequest command, DiscountModel.AddVendorToDiscountModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDiscounts))
            {
                return(AccessDeniedView());
            }

            var vendors = _vendorService.GetAllVendors(model.SearchVendorName, command.Page - 1, command.PageSize, true);

            //search for emails
            if (!(string.IsNullOrEmpty(model.SearchVendorEmail)))
            {
                var tempVendors = vendors.Where(x => x.Email.ToLowerInvariant().Contains(model.SearchVendorEmail.Trim()));
                vendors = new PagedList <Core.Domain.Vendors.Vendor>(tempVendors, command.Page - 1, command.PageSize);
            }

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

            return(Json(gridModel));
        }
Esempio n. 7
0
        public IActionResult VendorAddPopup(string discountId)
        {
            var model = new DiscountModel.AddVendorToDiscountModel();

            return(View(model));
        }