public async Task<IActionResult> CompanyInfo( Guid? siteId, int slp = 1) { var selectedSite = await siteManager.GetSiteForEdit(siteId); // only server admin site can edit other sites settings if (selectedSite.Id != siteManager.CurrentSite.Id) { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Company Info"], selectedSite.SiteName); } else { ViewData["Title"] = sr["Company Info"]; } var model = new CompanyInfoViewModel(); model.SiteId = selectedSite.Id; model.CompanyName = selectedSite.CompanyName; model.CompanyStreetAddress = selectedSite.CompanyStreetAddress; model.CompanyStreetAddress2 = selectedSite.CompanyStreetAddress2; model.CompanyLocality = selectedSite.CompanyLocality; model.CompanyRegion = selectedSite.CompanyRegion; model.CompanyPostalCode = selectedSite.CompanyPostalCode; model.CompanyCountry = selectedSite.CompanyCountry; model.CompanyPhone = selectedSite.CompanyPhone; model.CompanyFax = selectedSite.CompanyFax; model.CompanyPublicEmail = selectedSite.CompanyPublicEmail; model.AvailableCountries.Add(new SelectListItem { Text = sr["-Please select-"], Value = "" }); var countries = await geoDataManager.GetAllCountries(); var selectedCountryGuid = Guid.Empty; foreach (var country in countries) { if (country.ISOCode2 == model.CompanyCountry) { selectedCountryGuid = country.Id; } model.AvailableCountries.Add(new SelectListItem() { Text = country.Name, Value = country.ISOCode2.ToString() }); } if (selectedCountryGuid != Guid.Empty) { var states = await geoDataManager.GetGeoZonesByCountry(selectedCountryGuid); foreach (var state in states) { model.AvailableStates.Add(new SelectListItem() { Text = state.Name, Value = state.Code }); } } return View(model); }
public async Task<ActionResult> CompanyInfo(CompanyInfoViewModel model) { var selectedSite = await siteManager.GetSiteForEdit(model.SiteId); // only server admin site can edit other sites settings if (selectedSite.Id == siteManager.CurrentSite.Id) { ViewData["Title"] = sr["Company Info"]; } else { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Company Info"], selectedSite.SiteName); } if (selectedSite == null) { this.AlertDanger(sr["oops something went wrong."], true); return RedirectToAction("Index"); } if (!ModelState.IsValid) { return View(model); } if (model.SiteId == Guid.Empty) { this.AlertDanger(sr["oops something went wrong, site was not found."], true); return RedirectToAction("Index"); } selectedSite.CompanyName = model.CompanyName; selectedSite.CompanyStreetAddress = model.CompanyStreetAddress; selectedSite.CompanyStreetAddress2 = model.CompanyStreetAddress2; selectedSite.CompanyLocality = model.CompanyLocality; selectedSite.CompanyRegion = model.CompanyRegion; selectedSite.CompanyPostalCode = model.CompanyPostalCode; selectedSite.CompanyCountry = model.CompanyCountry; selectedSite.CompanyPhone = model.CompanyPhone; selectedSite.CompanyFax = model.CompanyFax; selectedSite.CompanyPublicEmail = model.CompanyPublicEmail; await siteManager.Update(selectedSite); this.AlertSuccess(string.Format(sr["Company Info for {0} wwas successfully updated."], selectedSite.SiteName), true); if ((siteManager.CurrentSite.IsServerAdminSite) && (siteManager.CurrentSite.Id != selectedSite.Id) ) { return RedirectToAction("CompanyInfo", new { siteId = model.SiteId }); } return RedirectToAction("CompanyInfo"); }
public async Task<ActionResult> CompanyInfo(CompanyInfoViewModel model) { ISiteSettings selectedSite = null; if (model.SiteGuid == siteManager.CurrentSite.SiteGuid) { selectedSite = siteManager.CurrentSite; ViewData["Title"] = "Company Info"; } else if (siteManager.CurrentSite.IsServerAdminSite) { selectedSite = await siteManager.Fetch(model.SiteGuid); ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Company Info", selectedSite.SiteName); } if (selectedSite == null) { this.AlertDanger("oops something went wrong.", true); return RedirectToAction("Index"); } if (!ModelState.IsValid) { return View(model); } if (model.SiteGuid == Guid.Empty) { this.AlertDanger("oops something went wrong, site was not found.", true); return RedirectToAction("Index"); } //model.SiteId = Site.SiteSettings.SiteId; //model.SiteGuid = Site.SiteSettings.SiteGuid; selectedSite.CompanyName = model.CompanyName; selectedSite.CompanyStreetAddress = model.CompanyStreetAddress; selectedSite.CompanyStreetAddress2 = model.CompanyStreetAddress2; selectedSite.CompanyLocality = model.CompanyLocality; selectedSite.CompanyRegion = model.CompanyRegion; selectedSite.CompanyPostalCode = model.CompanyPostalCode; selectedSite.CompanyCountry = model.CompanyCountry; selectedSite.CompanyPhone = model.CompanyPhone; selectedSite.CompanyFax = model.CompanyFax; selectedSite.CompanyPublicEmail = model.CompanyPublicEmail; bool result = await siteManager.Save(selectedSite); if (result) { this.AlertSuccess(string.Format("Company Info for <b>{0}</b> wwas successfully updated.", selectedSite.SiteName), true); } if ((siteManager.CurrentSite.IsServerAdminSite) && (siteManager.CurrentSite.SiteGuid != selectedSite.SiteGuid) ) { return RedirectToAction("CompanyInfo", new { siteGuid = model.SiteGuid }); } return RedirectToAction("CompanyInfo"); }