public ActionResult UserSettings() { string userId = User.Identity.GetUserId(); if (!string.IsNullOrEmpty(userId)) { RedirectToAction("Index", "Home"); } var settings = Mapper.Map <List <UserSettingViewModel> >(_settingService.AllUserSetting(userId)); var existingSettingsId = settings.Select(x => x.Id).ToList(); var defaultSettings = _settingService.AllSettings().Where(x => !existingSettingsId.Contains(x.Id)).ToList(); foreach (var setting in defaultSettings) { var userSettingViewModel = new UserSettingViewModel() { Id = 0, SettingId = setting.Id, SettingDescription = setting.SettingDescription, SettingType = setting.SettingValueType }; if (setting.SettingValueType == "System.Int32") { userSettingViewModel.SettingValue = _defaultNumberOfDays.ToString(); } else { userSettingViewModel.SettingValue = string.Empty; } settings.Add(userSettingViewModel); } var user = _applicationUserManager.FindById(userId); var model = new UserSettingsViewModel() { UserId = userId, Settings = settings, TwoFactorEnabled = user.TwoFactorEnabled }; return(View(model)); }