public void SetCustomerLocalizationModel(int customerId, CustomerLocalizationModel customerLocalizationModel) { var customerProfile = RbacEntities.CustomerProfiles.FirstOrDefault(m => m.CustomerId == customerId); // Language var settingFactory = new SettingsFactory(); Setting setting = settingFactory.GetListValue("Locale", customerLocalizationModel.LanguageId); if (setting != null) { settingFactory.Set(customerId, "CustomerLocale", setting.Value); // Write the local to customer.DefaultLocale also customerProfile.DefaultLocale = setting.Value; } // 12/ 24 hour format customerProfile.Is24HrFormat = customerLocalizationModel.Is24Hr; // TimeZone customerProfile.TimeZoneID = customerLocalizationModel.TimeZoneId; // Save changes. RbacEntities.SaveChanges(); }
public void SetIdentificationModel(int customerId, MaintenanceGroupIdentificationModel identificationModel) { var customerProfile = RbacEntities.CustomerProfiles.SingleOrDefault(m => m.CustomerId == customerId); if (customerProfile == null) { return; } customerProfile.DisplayName = identificationModel.DisplayName; var settingFactory = new SettingsFactory(); if (identificationModel.DefaultPassword != null) { settingFactory.Set(customerId, "DefaultPassword", identificationModel.DefaultPassword); } // Save customer contact SetCustomerContactModel(customerId, identificationModel.Contact); // Save Customer Localization data. SetCustomerLocalizationModel(customerId, identificationModel.Localization); RbacEntities.SaveChanges(); }
public CustomerContactModel GetCustomerContactModel(int customerId) { var customerContactModel = new CustomerContactModel(); var settingFactory = new SettingsFactory(); customerContactModel.FirstName = settingFactory.GetValue("CustomerContactFirstName", customerId); customerContactModel.LastName = settingFactory.GetValue("CustomerContactLastName", customerId); customerContactModel.FromEmailAddress = settingFactory.GetValue("CustomerContactEMail", customerId); customerContactModel.PhoneNumber = settingFactory.GetValue("CustomerContactPhoneNumber", customerId); return(customerContactModel); }
public MaintenanceGroupActivateModel CanActivate(int customerId) { var model = new MaintenanceGroupActivateModel(); GetCustomerBaseModel(customerId, model); var customerProfile = RbacEntities.CustomerProfiles.FirstOrDefault(m => m.CustomerId == customerId); var settingFactory = new SettingsFactory(); // Has a default password? string defaultPassword = settingFactory.GetValue("DefaultPassword", customerId); if (string.IsNullOrWhiteSpace(defaultPassword)) { model.Issues.Add(new MaintenanceGroupActivateIssue() { Description = "Default password is missing.", Controller = "MaintenanceGroups", Action = "EditMaintenanceGroup" }); } // Has a time zone if (customerProfile.TimeZoneID == null || customerProfile.TimeZoneID == -1) { model.Issues.Add(new MaintenanceGroupActivateIssue() { Description = "Select customer time zone.", Controller = "MaintenanceGroups", Action = "EditMaintenanceGroup" }); } // Can activate? model.CanActivate = !model.Issues.Any(); // Post a message that customer can be activated. if (model.CanActivate) { model.ActivateMessage = model.DisplayName + " may be activated."; } return(model); }
public MaintenanceGroupIdentificationModel GetIdentificationModel(int customerId) { var identificationModel = new MaintenanceGroupIdentificationModel(); identificationModel.CustomerId = customerId; var settingFactory = new SettingsFactory(); var customerProfile = RbacEntities.CustomerProfiles.SingleOrDefault(m => m.CustomerId == customerId); if (customerProfile != null) { GetCustomerBaseModel(customerId, identificationModel); identificationModel.DisplayName = customerProfile.DisplayName; identificationModel.DefaultPassword = settingFactory.GetValue("DefaultPassword", customerId); } // Get customer Address identificationModel.Contact = GetCustomerContactModel(customerId); // Get customer localization data. identificationModel.Localization = GetCustomerLocalizationModel(customerId); return(identificationModel); }
public void SetCustomerContactModel(int customerId, CustomerContactModel customerContactModel) { var settingFactory = new SettingsFactory(); if (customerContactModel.FirstName != null) { settingFactory.Set(customerId, "CustomerContactFirstName", customerContactModel.FirstName); } if (customerContactModel.LastName != null) { settingFactory.Set(customerId, "CustomerContactLastName", customerContactModel.LastName); } if (customerContactModel.FromEmailAddress != null) { settingFactory.Set(customerId, "CustomerContactEMail", customerContactModel.FromEmailAddress); } if (customerContactModel.PhoneNumber != null) { settingFactory.Set(customerId, "CustomerContactPhoneNumber", customerContactModel.PhoneNumber); } }
public CustomerLocalizationModel GetCustomerLocalizationModel(int customerId) { var customerLocalizationModel = new CustomerLocalizationModel(); // TimeZone // Get presently assign zone id. var customerProfile = RbacEntities.CustomerProfiles.FirstOrDefault(m => m.CustomerId == customerId); customerLocalizationModel.TimeZoneId = customerProfile == null ? -1 : customerProfile.TimeZoneID ?? -1; // Get list of possible zones. customerLocalizationModel.TimeZone.Add(new SelectListItem() { Text = "[Select Time Zone]", Value = "-1", Selected = customerLocalizationModel.TimeZoneId == -1 }); if (customerLocalizationModel.TimeZoneId == -1) { customerLocalizationModel.TimeZoneDisplay = ""; } foreach (var timeZone in RbacEntities.CustomerTimeZones) { customerLocalizationModel.TimeZone.Add(new SelectListItem() { Text = timeZone.TimeZoneName, Value = timeZone.TimeZoneID.ToString(), Selected = customerLocalizationModel.TimeZoneId == timeZone.TimeZoneID }); if (customerLocalizationModel.TimeZoneId == timeZone.TimeZoneID) { customerLocalizationModel.TimeZoneDisplay = timeZone.TimeZoneName; } } // Language customerLocalizationModel.LanguageDisplay = ""; var settingFactory = new SettingsFactory(); string locale = settingFactory.GetValue("CustomerLocale", customerId); customerLocalizationModel.Language = new List <SelectListItem>(); List <Setting> settingList = settingFactory.GetList("Locale"); foreach (Setting setting in settingList) { SelectListItem selectListItem = new SelectListItem() { Text = setting.Value, Value = setting.Id.ToString() }; if (locale != null && locale.Equals(setting.Value)) { selectListItem.Selected = true; customerLocalizationModel.LanguageId = setting.Id; customerLocalizationModel.LanguageDisplay = locale; } else { selectListItem.Selected = setting.Default; if (selectListItem.Selected) { customerLocalizationModel.LanguageId = setting.Id; } } customerLocalizationModel.Language.Add(selectListItem); } // Is there a selected or default item? If not add a "select X" item. if (customerLocalizationModel.LanguageId == 0) { customerLocalizationModel.Language.Insert(0, new SelectListItem() { Text = "[Select Language]", Value = "0", Selected = true }); } // 12/24 Hour Clock customerLocalizationModel.Is24Hr = false; var customer = RbacEntities.CustomerProfiles.FirstOrDefault(m => m.CustomerId == customerId); if (customer != null) { customerLocalizationModel.Is24Hr = customer.Is24HrFormat ?? false; } return(customerLocalizationModel); }