public HttpResponseMessage DeleteIgn([FromUri] LocationPreferenceModel prefModel) { if (!ModelState.IsValid) { return(Request.CreateResponseForInvalidModelState()); } var result = EventService.Instance.DeletePreference(prefModel.Id, prefModel.Key, PreferenceTypes.IGNORED); return(Request.CreateResponse(result ? HttpStatusCode.NoContent : HttpStatusCode.NotFound)); }
public HttpResponseMessage PostFav(LocationPreferenceModel prefModel) { if (!ModelState.IsValid) { return(Request.CreateResponseForInvalidModelState()); } var result = EventService.Instance.SetPreference(prefModel.Id, prefModel.Key, PreferenceTypes.FAVORITE); return(Request.CreateResponse(result ? HttpStatusCode.NoContent : HttpStatusCode.NotFound)); }
protected LocationPreferenceModel PrepareLocationPreferenceModel() { var selectedCountry = _workContext.CurrentCountry; var selectedCurrency = _workContext.WorkingCurrency; var allCurrency = _utilityService.GetAllCurrency(); var countries = _shippingService.GetActiveCountries(); var options = _shippingService.GetShippingOptionByCountryAndEnabled(selectedCountry.Id, true); var freeDeliveryOption = options.Where(x => x.FreeThreshold > 0).FirstOrDefault(); var freeDeliveryNote = ", FREE Delivery*"; if (selectedCountry.ISO3166Code != "GB") { freeDeliveryNote = freeDeliveryOption == null ? string.Empty : string.Format(", FREE {0} over {1}", freeDeliveryOption.Name, _priceFormatter.FormatPrice(freeDeliveryOption.FreeThreshold)); } var model = new LocationPreferenceModel { SelectedCountryName = selectedCountry.Name, SelectedCountryCode = selectedCountry.ISO3166Code, FreeDeliveryNote = freeDeliveryNote }; model.Note = string.Format("Delivery options are set based on shipping to {0}, but can be amended below.", selectedCountry.Name); model.AvailableCountries = countries .Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString(), Selected = x.Id == selectedCountry.Id }) .ToList(); model.AvailableLocaleCurrencies = allCurrency .Select(x => new SelectListItem { Text = x.Symbol + " " + x.CurrencyCode, Value = x.CurrencyCode, Selected = x.CurrencyCode == selectedCurrency.CurrencyCode }) .ToList(); return(model); }
public ActionResult ChangeLocationPreference(LocationPreferenceModel model, string returnUrl = "") { var currency = _utilityService.GetCurrencyByCurrencyCode(model.CurrencyCode); if (currency != null) { _workContext.WorkingCurrency = currency; } var country = _shippingService.GetCountryById(model.CountryId); if (country != null) { _workContext.CurrentCountry = country; } var profileId = _workContext.CurrentProfile.Id; var options = _cartService.GetCustomerShippingOptionByCountryAndPriority(profileId); // Select default option _utilityService.SaveAttribute(profileId, "Profile", SystemCustomerAttributeNames.SelectedShippingOption, options[0].Id.ToString()); // Home page if (string.IsNullOrEmpty(returnUrl)) { returnUrl = Url.RouteUrl("Home"); } // Prevent open redirection attack if (!Url.IsLocalUrl(returnUrl)) { returnUrl = Url.RouteUrl("Home"); } return(Redirect(returnUrl)); }