public ActionResult Init(string id, InitSettingsModel model) { var company = Repository.GetById(id); company.CompanySettings = new List <CompanySetting>(); var path = HostingEnvironment.MapPath("~/assets/DefaultSettings/Common.json"); if (System.IO.File.Exists(path)) { var json = System.IO.File.ReadAllText(path); var settings = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); var d = new Dictionary <string, Value>(); foreach (var setting in settings) { d.Add(setting.Key, new Value(setting.Value, true)); } AddOrUpdateSettings(d, company); } AddOrUpdateSettings(model.Settings, company); UpdateCompany(company); return(RedirectToAction("Index", "Home", new { area = "Customer", companyId = id })); }
public ActionResult Init(string id, string city = null) { CityInfo cityInfo = null; if (!string.IsNullOrEmpty(city)) { cityInfo = new GoogleApi().GetCityInfo(city); } var company = Repository.GetById(id); if (company == null) { return(HttpNotFound()); } var model = new InitSettingsModel { Company = company }; model.CityInfo = cityInfo == null ? "" : cityInfo.Name; model.Settings = new Dictionary <string, Value>(); model.Settings.Add("Direction.FlateRate", new Value( company.Application.FlagDropRate.HasValue ? company.Application.FlagDropRate.Value.ToString() : "2.25", false)); if (company.Application.UnitOfLength == UnitOfLength.Kilometers) { model.Settings.Add("Direction.RatePerKm", new Value( company.Application.MileageRate.HasValue ? company.Application.MileageRate.Value.ToString() : "1.25", false)); } else { model.Settings.Add("Direction.RatePerKm", new Value( company.Application.MileageRate.HasValue ? (Convert.ToDouble(company.Application.MileageRate.Value) * 0.390625).ToString() : "1.25", false)); // Convertion in the questionnaire is invalid, this fixes the issue } model.Settings.Add("DistanceFormat", new Value( company.Application.UnitOfLength == UnitOfLength.Kilometers ? "Km" : "Mile", false)); model.Settings.Add("GeoLoc.DefaultLatitude", new Value(cityInfo != null ? cityInfo.Center.Latitude.ToString(CultureInfo.InstalledUICulture) : "", true)); model.Settings.Add("GeoLoc.DefaultLongitude", new Value(cityInfo != null ? cityInfo.Center.Longitude.ToString(CultureInfo.InstalledUICulture) : "", true)); if (cityInfo == null) { model.Settings.Add("GeoLoc.SearchFilter", new Value(@"{0},ottawa,on,canada®ion=ca", true)); model.Settings.Add("Client.LowerLeftLatitude", new Value("0", true)); model.Settings.Add("Client.LowerLeftLongitude", new Value("0", true)); model.Settings.Add("Client.UpperRightLatitude", new Value("0", true)); model.Settings.Add("Client.UpperRightLongitude", new Value("0", true)); } else { model.Settings.Add("GeoLoc.SearchFilter", new Value(@"{0}" + string.Format(",{0}&bounds={1},{2}|{3},{4}", cityInfo.Name.Replace(" ", "+"), cityInfo.SouthwestCoordinate.Latitude, cityInfo.SouthwestCoordinate.Longitude, cityInfo.NortheastCoordinate.Latitude, cityInfo.NortheastCoordinate.Longitude), true)); model.Settings.Add("Client.LowerLeftLatitude", new Value(cityInfo.SouthwestCoordinate.Latitude.ToString(CultureInfo.InvariantCulture), true)); model.Settings.Add("Client.LowerLeftLongitude", new Value(cityInfo.SouthwestCoordinate.Longitude.ToString(CultureInfo.InvariantCulture), true)); model.Settings.Add("Client.UpperRightLatitude", new Value(cityInfo.NortheastCoordinate.Latitude.ToString(CultureInfo.InvariantCulture), true)); model.Settings.Add("Client.UpperRightLongitude", new Value(cityInfo.NortheastCoordinate.Longitude.ToString(CultureInfo.InvariantCulture), true)); } model.Settings.Add("DefaultPhoneNumber", new Value( string.IsNullOrEmpty(company.Application.CompanyPhoneNumber) ? "" : company.Application.CompanyPhoneNumber.Replace("-", ""), true)); model.Settings.Add("DefaultPhoneNumberDisplay", new Value(company.Application.CompanyPhoneNumber, true)); //company.CompanyKey model.Settings.Add("APNS.ProductionCertificatePath", new Value( string.Format("../../../Certificates/{0}.p12", company.CompanyKey), false)); model.Settings.Add("GCM.PackageName", new Value(string.Format("com.apcurium.MK.{0}", company.CompanyKey), false)); model.Settings.Add("Receipt.Note", new Value("Thank You!<br>" + company.Application.AppName, false)); if (cityInfo == null) { model.Settings.Add("IBS.TimeDifference", new Value("0", true)); } else { model.Settings.Add("IBS.TimeDifference", new Value((-1 * (TimeSpan.FromHours(-5).Ticks - cityInfo.TimeDifference.Ticks)).ToString(), true)); } model.Settings.Add("TaxiHail.ApplicationName", new Value(company.Application.AppName, true)); model.Settings.Add("TaxiHail.ApplicationKey", new Value(company.CompanyKey, true)); model.Settings.Add("TaxiHail.AccentColor", new Value(String.IsNullOrEmpty(company.Style.CompanyColor) ? "#0057a3" : company.Style.CompanyColor, false)); model.Settings.Add("TaxiHail.EmailFontColor", new Value("#000000", false)); model.Settings.Add("TaxiHail.SiteName", new Value(company.CompanyKey, true)); model.Settings.Add("AndroidSigningKeyAlias", new Value("MK" + company.CompanyKey, false)); model.Settings.Add("AndroidSigningKeyPassStorePass", new Value(string.Format("mk{0}0001.", company.CompanyKey), false)); model.Settings.Add("ApplicationName", new Value(company.Application.AppName, true)); model.Settings.Add("AppName", new Value(company.Application.AppName, true)); model.Settings.Add("Package", new Value("com.apcurium.MK." + company.CompanyKey, false)); model.Settings.Add("Client.AboutUsUrl", new Value(company.Application.AboutUsLink, true)); model.Settings.Add("SupportEmail", new Value(company.Application.SupportContactEmail, true)); model.Settings.Add("Client.SupportEmail", new Value(company.Application.SupportContactEmail, true)); return(View(model)); }