コード例 #1
0
        public ActionResult DeleteProductType(string btnId, string formId, int Id, ShippingByProductTypeModel model)
        {
            if (ModelState.IsValid)
            {
                if (Id != model.Id)
                {
                    return(HttpNotFound());
                }

                var entity = _shippingByProductTypeService.GetById(Id);
                if (entity != null)
                {
                    _shippingByProductTypeService.DeleteShippingByProductTypeRecord(entity);
                }
            }
            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            var selectedStore = _storeService.GetStoreById(model.StoreId);

            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString(), Selected = (selectedStore != null && store.Id == selectedStore.Id)
                });
            }
            return(View("~/Plugins/Shipping.RateByDistrict/Views/RateByProductTypePopup.cshtml", model));
        }
コード例 #2
0
        public ActionResult ProductType(string btnId, string formId, int Id)
        {
            var model = new ShippingByProductTypeModel();

            if (Id == 0)
            {
                model = new ShippingByProductTypeModel
                {
                    Id = 0,
                    AdditionalFixedCost = 0,
                    ProductTypeName     = "",
                    StoreId             = 0,
                };
            }
            else
            {
                var entity = _shippingByProductTypeService.GetById(Id);
                if (entity == null)
                {
                    return(HttpNotFound());
                }
                model = new ShippingByProductTypeModel
                {
                    Id = entity.Id,
                    AdditionalFixedCost = entity.AdditionalFixedCost,
                    ProductTypeName     = entity.ProductTypeName,
                    StoreId             = entity.StoreId,
                };
            }
            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            var selectedStore = _storeService.GetStoreById(model.StoreId);

            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString(), Selected = (selectedStore != null && store.Id == selectedStore.Id)
                });
            }
            return(View("~/Plugins/Shipping.RateByDistrict/Views/RateByProductTypePopup.cshtml", model));
        }