/// <summary> /// Parse comma-separated Hosts /// </summary> /// <param name="store">Store</param> /// <returns>Comma-separated hosts</returns> public virtual string[] ParseHostValues(Core.Domain.Stores.Store store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } var parsedValues = new List <string>(); if (string.IsNullOrEmpty(store.Hosts)) { return(parsedValues.ToArray()); } var hosts = store.Hosts.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var host in hosts) { var tmp = host.Trim(); if (!string.IsNullOrEmpty(tmp)) { parsedValues.Add(tmp); } } return(parsedValues.ToArray()); }
/// <summary> /// Inserts a store /// </summary> /// <param name="store">Store</param> public virtual void InsertStore(Core.Domain.Stores.Store store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } _storeRepository.Insert(store); //event notification //_eventPublisher.EntityInserted(store); }
/// <summary> /// Indicates whether a store contains a specified host /// </summary> /// <param name="store">Store</param> /// <param name="host">Host</param> /// <returns>true - contains, false - no</returns> public virtual bool ContainsHostValue(Core.Domain.Stores.Store store, string host) { if (store == null) { throw new ArgumentNullException(nameof(store)); } if (string.IsNullOrEmpty(host)) { return(false); } var contains = ParseHostValues(store).Any(x => x.Equals(host, StringComparison.InvariantCultureIgnoreCase)); return(contains); }
/// <summary> /// Deletes a store /// </summary> /// <param name="store">Store</param> public virtual void DeleteStore(Core.Domain.Stores.Store store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } var allStores = GetAllStores(); if (allStores.Count == 1) { throw new Exception("You cannot delete the only configured store"); } _storeRepository.Delete(store); //event notification //_eventPublisher.EntityDeleted(store); }
/// <summary> /// Add store tokens /// </summary> /// <param name="tokens">List of already added tokens</param> /// <param name="store">Store</param> /// <param name="emailAccount">Email account</param> public virtual void AddStoreTokens(IList <Token> tokens, Core.Domain.Stores.Store store, EmailAccount emailAccount) { if (emailAccount == null) { throw new ArgumentNullException(nameof(emailAccount)); } tokens.Add(new Token("Store.Name", store.Name)); tokens.Add(new Token("Store.URL", store.Url, true)); tokens.Add(new Token("Store.Email", emailAccount.Email)); tokens.Add(new Token("Store.CompanyName", store.CompanyName)); tokens.Add(new Token("Store.CompanyAddress", store.CompanyAddress)); tokens.Add(new Token("Store.CompanyPhoneNumber", store.CompanyPhoneNumber)); tokens.Add(new Token("Store.CompanyVat", store.CompanyVat)); tokens.Add(new Token("Facebook.URL", _storeInformationSettings.FacebookLink)); tokens.Add(new Token("Twitter.URL", _storeInformationSettings.TwitterLink)); tokens.Add(new Token("YouTube.URL", _storeInformationSettings.YoutubeLink)); }
public IActionResult EditRateByWeightByTotalPopup(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } ShippingByWeightByTotalRecord sbw = _shippingByWeightService.GetById(id); if (sbw == null) { //no record found with the specified id return(RedirectToAction("Configure")); } ShippingByWeightByTotalModel model = new ShippingByWeightByTotalModel { Id = sbw.Id, StoreId = sbw.StoreId, WarehouseId = sbw.WarehouseId, CountryId = sbw.CountryId, StateProvinceId = sbw.StateProvinceId, Zip = sbw.Zip, ShippingMethodId = sbw.ShippingMethodId, WeightFrom = sbw.WeightFrom, WeightTo = sbw.WeightTo, OrderSubtotalFrom = sbw.OrderSubtotalFrom, OrderSubtotalTo = sbw.OrderSubtotalTo, AdditionalFixedCost = sbw.AdditionalFixedCost, PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal, RatePerWeightUnit = sbw.RatePerWeightUnit, LowerWeightLimit = sbw.LowerWeightLimit, PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)?.CurrencyCode, BaseWeightIn = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)?.Name, MontoDolar = sbw.MontoDolar }; IList <Core.Domain.Shipping.ShippingMethod> shippingMethods = _shippingService.GetAllShippingMethods(); if (!shippingMethods.Any()) { return(Content("No shipping methods can be loaded")); } Core.Domain.Stores.Store selectedStore = _storeService.GetStoreById(sbw.StoreId); Core.Domain.Shipping.Warehouse selectedWarehouse = _shippingService.GetWarehouseById(sbw.WarehouseId); Core.Domain.Shipping.ShippingMethod selectedShippingMethod = _shippingService.GetShippingMethodById(sbw.ShippingMethodId); Country selectedCountry = _countryService.GetCountryById(sbw.CountryId); StateProvince selectedState = _stateProvinceService.GetStateProvinceById(sbw.StateProvinceId); //stores model.AvailableStores.Add(new SelectListItem { Text = "*", Value = "0" }); foreach (Core.Domain.Stores.Store store in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = store.Name, Value = store.Id.ToString(), Selected = selectedStore != null && store.Id == selectedStore.Id }); } //warehouses model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = "0" }); foreach (Core.Domain.Shipping.Warehouse warehouse in _shippingService.GetAllWarehouses()) { model.AvailableWarehouses.Add(new SelectListItem { Text = warehouse.Name, Value = warehouse.Id.ToString(), Selected = selectedWarehouse != null && warehouse.Id == selectedWarehouse.Id }); } //shipping methods foreach (Core.Domain.Shipping.ShippingMethod 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" }); IList <Country> countries = _countryService.GetAllCountries(showHidden: true); foreach (Country c in countries) { model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString(), Selected = selectedCountry != null && c.Id == selectedCountry.Id }); } //states List <StateProvince> states = selectedCountry != null?_stateProvinceService.GetStateProvincesByCountryId(selectedCountry.Id, showHidden : true).ToList() : new List <StateProvince>(); model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "0" }); foreach (StateProvince s in states) { model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString(), Selected = selectedState != null && s.Id == selectedState.Id }); } return(View("~/Plugins/Shipping.FixedByWeightByTotal/Views/EditRateByWeightByTotalPopup.cshtml", model)); }
/// <summary> /// Sends password recovery message to a customer /// </summary> /// <param name="customer">Customer instance</param> /// <param name="languageId">Message language identifier</param> /// <returns>Queued email identifier</returns> public virtual IList <Guid> SendCustomerPasswordRecoveryMessage(Core.Domain.Customers.Customer customer, Guid languageId, Core.Domain.Stores.Store store) { if (customer == null) { throw new ArgumentNullException(nameof(customer)); } languageId = EnsureLanguageIsActive(languageId, store.Id); var messageTemplates = GetActiveMessageTemplates(MessageTemplateSystemNames.CustomerPasswordRecoveryMessage, store.Id); if (!messageTemplates.Any()) { return(new List <Guid>()); } //tokens var commonTokens = new List <Token>(); _messageTokenProvider.AddCustomerTokens(commonTokens, customer); return(messageTemplates.Select(messageTemplate => { //email account var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId); var tokens = new List <Token>(commonTokens); _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount); var toEmail = customer.Email; var toName = _customerService.GetCustomerFullName(customer); return SendNotification(messageTemplate, emailAccount, languageId, tokens, toEmail, toName); }).ToList()); }