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 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);
        }