Exemplo n.º 1
0
        public async Task <IActionResult> Create(ManufacturerModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                if (_workContext.CurrentCustomer.IsStaff())
                {
                    model.LimitedToStores  = true;
                    model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }

                var manufacturer = await _manufacturerViewModelService.InsertManufacturerModel(model);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Manufacturers.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = manufacturer.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            //templates
            await _manufacturerViewModelService.PrepareTemplatesModel(model);

            //discounts
            await _manufacturerViewModelService.PrepareDiscountModel(model, null, true);

            //ACL
            await model.PrepareACLModel(null, true, _customerService);

            //Stores
            await model.PrepareStoresMappingModel(null, _storeService, true, _workContext.CurrentCustomer.StaffStoreId);

            //sort options
            _manufacturerViewModelService.PrepareSortOptionsModel(model);

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([FromServices] CatalogSettings catalogSettings)
        {
            var model = new ManufacturerModel();

            //locales
            await AddLocales(_languageService, model.Locales);

            //templates
            await _manufacturerViewModelService.PrepareTemplatesModel(model);

            //discounts
            await _manufacturerViewModelService.PrepareDiscountModel(model, null, true);

            //ACL
            await model.PrepareACLModel(null, false, _customerService);

            //Stores
            await model.PrepareStoresMappingModel(null, _storeService, false, _workContext.CurrentCustomer.StaffStoreId);

            //default values
            model.PageSize        = catalogSettings.DefaultManufacturerPageSize;
            model.PageSizeOptions = catalogSettings.DefaultManufacturerPageSizeOptions;
            model.Published       = true;
            model.AllowCustomersToSelectPageSize = true;
            //sort options
            _manufacturerViewModelService.PrepareSortOptionsModel(model);

            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(ManufacturerModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var manufacturer = await _manufacturerViewModelService.InsertManufacturerModel(model);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Manufacturers.Added"));
                return(continueEditing ? RedirectToAction("Edit", new { id = manufacturer.Id }) : RedirectToAction("List"));
            }

            //If we got this far, something failed, redisplay form
            //templates
            await _manufacturerViewModelService.PrepareTemplatesModel(model);

            //discounts
            await _manufacturerViewModelService.PrepareDiscountModel(model, null, true);

            //ACL
            await model.PrepareACLModel(null, true, _customerService);

            //Stores
            await model.PrepareStoresMappingModel(null, true, _storeService);

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(ManufacturerModel model, bool continueEditing)
        {
            var manufacturer = await _manufacturerService.GetManufacturerById(model.Id);

            if (manufacturer == null)
            {
                //No manufacturer found with the specified id
                return(RedirectToAction("List"));
            }

            if (_workContext.CurrentCustomer.IsStaff())
            {
                if (!manufacturer.AccessToEntityByStore(_workContext.CurrentCustomer.StaffStoreId))
                {
                    return(RedirectToAction("Edit", new { id = manufacturer.Id }));
                }
            }
            if (ModelState.IsValid)
            {
                if (_workContext.CurrentCustomer.IsStaff())
                {
                    model.LimitedToStores  = true;
                    model.SelectedStoreIds = new string[] { _workContext.CurrentCustomer.StaffStoreId };
                }
                manufacturer = await _manufacturerViewModelService.UpdateManufacturerModel(manufacturer, model);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Manufacturers.Updated"));

                if (continueEditing)
                {
                    //selected tab
                    await SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = manufacturer.Id }));
                }
                return(RedirectToAction("List"));
            }


            //If we got this far, something failed, redisplay form
            //templates
            await _manufacturerViewModelService.PrepareTemplatesModel(model);

            //discounts
            await _manufacturerViewModelService.PrepareDiscountModel(model, manufacturer, true);

            //ACL
            await model.PrepareACLModel(manufacturer, true, _customerService);

            //Stores
            await model.PrepareStoresMappingModel(manufacturer, _storeService, true, _workContext.CurrentCustomer.StaffStoreId);

            //sort options
            _manufacturerViewModelService.PrepareSortOptionsModel(model);

            return(View(model));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(ManufacturerModel model, bool continueEditing)
        {
            var manufacturer = await _manufacturerService.GetManufacturerById(model.Id);

            if (manufacturer == null)
            {
                //No manufacturer found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                manufacturer = await _manufacturerViewModelService.UpdateManufacturerModel(manufacturer, model);

                SuccessNotification(_localizationService.GetResource("Admin.Catalog.Manufacturers.Updated"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = manufacturer.Id }));
                }
                return(RedirectToAction("List"));
            }


            //If we got this far, something failed, redisplay form
            //templates
            await _manufacturerViewModelService.PrepareTemplatesModel(model);

            //discounts
            await _manufacturerViewModelService.PrepareDiscountModel(model, manufacturer, true);

            //ACL
            await model.PrepareACLModel(manufacturer, true, _customerService);

            //Stores
            await model.PrepareStoresMappingModel(manufacturer, true, _storeService);

            return(View(model));
        }
        public IActionResult Create([FromServices] CatalogSettings catalogSettings)
        {
            var model = new ManufacturerModel();

            //locales
            AddLocales(_languageService, model.Locales);
            //templates
            _manufacturerViewModelService.PrepareTemplatesModel(model);
            //discounts
            _manufacturerViewModelService.PrepareDiscountModel(model, null, true);
            //ACL
            model.PrepareACLModel(null, false, _customerService);
            //Stores
            model.PrepareStoresMappingModel(null, false, _storeService);
            //default values
            model.PageSize        = catalogSettings.DefaultManufacturerPageSize;
            model.PageSizeOptions = catalogSettings.DefaultManufacturerPageSizeOptions;
            model.Published       = true;
            model.AllowCustomersToSelectPageSize = true;

            return(View(model));
        }