public ActionResult AddPopup(string btnId, string formId, ShippingFreeOrdersOverModel model) { var sbw = new FreeShippingByOrderTotalsRecord() { CountryId = model.CountryId, StateProvinceId = model.StateProvinceId, Zip = model.Zip == "*" ? null : model.Zip, ShippingMethodId = model.ShippingMethodId, OrderOver = model.OrderOver, }; _freeShippingByOrderTotalService.InsertFreeShippingRecord(sbw); ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return(View("CLF.Plugin.Shipping.FreeShipping.Views.FreeShipping.AddPopup", model)); }
//add public ActionResult AddPopup() { var model = new ShippingFreeOrdersOverModel(); model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode; var shippingMethods = _shippingService.GetAllShippingMethods(); if (shippingMethods.Count == 0) { return(Content("No shipping methods can be loaded")); } //shipping methods foreach (var sm in shippingMethods) { model.AvailableShippingMethods.Add(new SelectListItem() { Text = sm.Name, Value = sm.Id.ToString() }); } //countries model.AvailableCountries.Add(new SelectListItem() { Text = "*", Value = "0" }); var countries = _countryService.GetAllCountries(true); foreach (var c in countries) { model.AvailableCountries.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } //states model.AvailableStates.Add(new SelectListItem() { Text = "*", Value = "0" }); return(View("CLF.Plugin.Shipping.FreeShipping.Views.FreeShipping.AddPopup", model)); }
public ActionResult EditPopup(string btnId, string formId, ShippingFreeOrdersOverModel model) { var sbw = _freeShippingByOrderTotalService.GetById(model.Id); if (sbw == null) { //No record found with the specified id return(RedirectToAction("Configure")); } sbw.CountryId = model.CountryId; sbw.StateProvinceId = model.StateProvinceId; sbw.Zip = model.Zip == "*" ? null : model.Zip; sbw.ShippingMethodId = model.ShippingMethodId; sbw.OrderOver = model.OrderOver; _freeShippingByOrderTotalService.UpdateFreeShippingRecord(sbw); ViewBag.RefreshPage = true; ViewBag.btnId = btnId; ViewBag.formId = formId; return(View("CLF.Plugin.Shipping.FreeShipping.Views.FreeShipping.EditPopup", model)); }
public ActionResult ConditionsList(GridCommand command) { var records = _freeShippingByOrderTotalService.GetAll(command.Page - 1, command.PageSize); var sbwModel = records.Select(x => { var m = new ShippingFreeOrdersOverModel() { Id = x.Id, CountryId = x.CountryId, OrderOver = x.OrderOver, StateProvinceId = x.StateProvinceId, ShippingMethodId = x.ShippingMethodId, }; var shippingMethod = _shippingService.GetShippingMethodById(x.ShippingMethodId); m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable"; var c = _countryService.GetCountryById(x.CountryId); m.CountryName = (c != null) ? c.Name : "*"; var s = _stateProvinceService.GetStateProvinceById(x.StateProvinceId); m.StateProvinceName = (s != null) ? s.Name : "*"; m.Zip = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*"; return(m); }) .ToList(); var model = new GridModel <ShippingFreeOrdersOverModel> { Data = sbwModel, Total = records.TotalCount }; return(new JsonResult { Data = model }); }
//edit public ActionResult EditPopup(int id) { var sbw = _freeShippingByOrderTotalService.GetById(id); if (sbw == null) { //No record found with the specified id return(RedirectToAction("Configure")); } var model = new ShippingFreeOrdersOverModel() { Id = sbw.Id, CountryId = sbw.CountryId, StateProvinceId = sbw.StateProvinceId, Zip = sbw.Zip, OrderOver = sbw.OrderOver, PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode }; var shippingMethods = _shippingService.GetAllShippingMethods(); if (shippingMethods.Count == 0) { return(Content("No shipping methods can be loaded")); } var selectedShippingMethod = _shippingService.GetShippingMethodById(sbw.ShippingMethodId); var selectedCountry = _countryService.GetCountryById(sbw.CountryId); var selectedState = _stateProvinceService.GetStateProvinceById(sbw.StateProvinceId); //shipping methods foreach (var sm in shippingMethods) { model.AvailableShippingMethods.Add(new SelectListItem() { Text = sm.Name, Value = sm.Id.ToString(), Selected = (selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id) }); } //countries model.AvailableCountries.Add(new SelectListItem() { Text = "*", Value = "0" }); var countries = _countryService.GetAllCountries(true); foreach (var c in countries) { model.AvailableCountries.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString(), Selected = (selectedCountry != null && c.Id == selectedCountry.Id) }); } //states var states = selectedCountry != null?_stateProvinceService.GetStateProvincesByCountryId(selectedCountry.Id, true).ToList() : new List <StateProvince>(); model.AvailableStates.Add(new SelectListItem() { Text = "*", Value = "0" }); foreach (var s in states) { model.AvailableStates.Add(new SelectListItem() { Text = s.Name, Value = s.Id.ToString(), Selected = (selectedState != null && s.Id == selectedState.Id) }); } return(View("CLF.Plugin.Shipping.FreeShipping.Views.FreeShipping.EditPopup", model)); }