public IActionResult ExportCsv() { string fileName = String.Format("states_{0}_{1}.txt", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4)); var states = _stateProvinceService.GetStateProvinces(true); string result = _exportManager.ExportStatesToTxt(states); return(File(Encoding.UTF8.GetBytes(result), "text/csv", fileName)); }
public virtual IActionResult ExportCsv() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCountries)) { return(AccessDeniedView()); } var fileName = $"states_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}_{CommonHelper.GenerateRandomDigitCode(4)}.txt"; var states = _stateProvinceService.GetStateProvinces(true); var result = _exportManager.ExportStatesToTxt(states); return(File(Encoding.UTF8.GetBytes(result), MimeTypes.TextCsv, fileName)); }
public ActionResult ExportCsv() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCountries)) { return(AccessDeniedView()); } string fileName = String.Format("states_{0}_{1}.txt", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4)); var states = _stateProvinceService.GetStateProvinces(true); string result = _exportManager.ExportStatesToTxt(states); return(File(Encoding.UTF8.GetBytes(result), "text/csv", fileName)); }
protected virtual void PrepareAllProvinceModel(CityModel model) { if (model == null) { throw new ArgumentNullException("model"); } //model.Provinces.Add(new SelectListItem //{ // Text = "NA", // Value = "0" //}); var stateProvinces = _stateProvinceService.GetStateProvinces(); foreach (var p in stateProvinces) { model.Provinces.Add(new SelectListItem { Text = p.Name, Value = p.Id.ToString() }); } }
/// <summary> /// Gets all states/provinces /// </summary> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>States</returns> IList <StateProvince> GetStateProvinces(bool showHidden = false) { return(_stateProvinceService.GetStateProvinces(showHidden)); }
public ActionResult PaymentInfo() { var model = new PaymentInfoModel(); //years for (int i = 0; i < 15; i++) { string year = Convert.ToString(DateTime.Now.Year + i); model.ExpireYears.Add(new SelectListItem { Text = year, Value = year, }); } //months for (int i = 1; i <= 12; i++) { string text = (i < 10) ? "0" + i : i.ToString(); model.ExpireMonths.Add(new SelectListItem { Text = text, Value = text, }); } ViewBag.PublicKey = _stripePaymentSettings.PublicApiKey; ViewBag.BillingAddress = _workContext.CurrentCustomer.BillingAddress; PluginDescriptor nopTemplatesOnePageCheckout = _pluginFinder.GetPluginDescriptorBySystemName("SevenSpikes.Nop.Plugins.RealOnePageCheckout"); bool hasNpOpcInstalled = nopTemplatesOnePageCheckout != null && nopTemplatesOnePageCheckout.Installed; if (!hasNpOpcInstalled) { IList <Country> countries = new List <Country>(); IList <StateProvince> provinces = new List <StateProvince>(); if (!_cacheManager.IsSet(_countriesCacheKey)) { countries = _countryService.GetAllCountriesForBilling(); _cacheManager.Set(_countriesCacheKey, countries, _cacheExpirationInMinutes); } else { countries = _cacheManager.Get <IList <Country> >(_countriesCacheKey); } if (!_cacheManager.IsSet(_provincesCacheKey)) { provinces = _stateProvinceService.GetStateProvinces(); _cacheManager.Set(_provincesCacheKey, provinces, _cacheExpirationInMinutes); } else { provinces = _cacheManager.Get <IList <StateProvince> >(_provincesCacheKey); } ViewBag.Countries = countries.Select(c => new { Id = c.Id, TwoLeterIsoCode = c.TwoLetterIsoCode }); ViewBag.Provinces = provinces.Select(c => new { Id = c.Id, Abbreviation = c.Abbreviation }); return(View("~/Plugins/Payments.Stripe/Views/Stripe/PaymentInfo.cshtml", model)); } else { IList <Country> countries = new List <Country>(); IList <StateProvince> provinces = new List <StateProvince>(); if (!_cacheManager.IsSet(_countriesCacheKey)) { countries = _countryService.GetAllCountriesForBilling(); _cacheManager.Set(_countriesCacheKey, countries, _cacheExpirationInMinutes); } else { countries = _cacheManager.Get <IList <Country> >(_countriesCacheKey); } if (!_cacheManager.IsSet(_provincesCacheKey)) { provinces = _stateProvinceService.GetStateProvinces(); _cacheManager.Set(_provincesCacheKey, provinces, _cacheExpirationInMinutes); } else { provinces = _cacheManager.Get <IList <StateProvince> >(_provincesCacheKey); } ViewBag.Countries = countries.Select(c => new { Id = c.Id, TwoLeterIsoCode = c.TwoLetterIsoCode }); ViewBag.Provinces = provinces.Select(c => new { Id = c.Id, Abbreviation = c.Abbreviation }); return(View("~/Plugins/Payments.Stripe/Views/Stripe/PaymentInfoOpc.cshtml", model)); } }