public IActionResult Index() { string jobProfile = JobProfile.Applicant.ToString(); if (User.Identity.IsAuthenticated) { jobProfile = GetSessionValue(SessionValues.JobProfile); if (string.IsNullOrWhiteSpace(jobProfile)) { UserPreferencesViewModel userPreferences = UserPreferencesAppService.GetByUserId(CurrentUserId); if (userPreferences == null || userPreferences.JobProfile == 0) { return(View("NoJobProfile")); } else { SetSessionValue(SessionValues.JobProfile, userPreferences.JobProfile.ToString()); jobProfile = userPreferences.JobProfile.ToString(); } } } ViewData["jobProfile"] = jobProfile; return(View()); }
public async Task <IActionResult> EditPreferencesSaved(UserPreferencesViewModel userPreferenceViewModel) { //check for previously saved prefernce var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var previousPreferences = await _preferencesClient.RetrieveUserPreferences(userId); if (previousPreferences == null) { //Redirect user } previousPreferences.Diet = userPreferenceViewModel?.Diet; previousPreferences.Intolerances = !string.IsNullOrEmpty(userPreferenceViewModel.Intolerances.ToString()) ? userPreferenceViewModel.Intolerances.ToString() : ""; previousPreferences.MaxCalorie = userPreferenceViewModel?.MaxCalorie; previousPreferences.MaxCarb = userPreferenceViewModel?.MaxCarb; previousPreferences.MaxProtein = userPreferenceViewModel?.MaxProtein; previousPreferences.MinProtein = userPreferenceViewModel?.MinProtein; _context.Update(previousPreferences); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(UserPreferences))); }
public ActionResult UserPreferences() { try { using (var db = new whoaverseEntities()) { var userPreferences = db.Userpreferences.Find(User.Identity.Name); if (userPreferences != null) { // load existing preferences and return to view engine var tmpModel = new UserPreferencesViewModel { Disable_custom_css = userPreferences.Disable_custom_css, Night_mode = userPreferences.Night_mode, OpenLinksInNewTab = userPreferences.Clicking_mode, Enable_adult_content = userPreferences.Enable_adult_content, Public_subscriptions = userPreferences.Public_subscriptions, Topmenu_from_subscriptions = userPreferences.Topmenu_from_subscriptions }; return(PartialView("_UserPreferences", tmpModel)); } else { var tmpModel = new UserPreferencesViewModel(); return(PartialView("_UserPreferences", tmpModel)); } } } catch (Exception) { return(new EmptyResult()); } }
public IActionResult Languages(UserPreferencesViewModel vm) { if (!ModelState.IsValid) { return(View(vm)); } try { vm.UserId = CurrentUserId; userPreferencesAppService.Save(CurrentUserId, vm); SetPreferencesCookies(vm); SetAspNetCultureCookie(vm.UiLanguage); StatusMessage = "Your preferences were updated"; return(RedirectToAction(nameof(Languages))); } catch (Exception ex) { string msg = $"Unable to save your preferences."; logger.Log(LogLevel.Error, ex, msg); throw new CustomApplicationException(msg); } }
public async Task <IHttpActionResult> UpdateUserInfo(UserPreferencesViewModel preferences) { ApplicationUser user = GetAuthUser(); bool newEmail = !string.IsNullOrEmpty(preferences.email) && preferences.email != user.Email && !user.EmailConfirmed; user.Email = preferences.email; user.SearchVisible = preferences.searchVisible; try { _dbContext.SaveChanges(); if (newEmail) { string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id).ConfigureAwait(false); var callbackUrl = Url.Link("ActionApi", new { controller = "Account", action = "ConfirmEmail", userId = user.Id, code }); await UserManager.SendEmailAsync(user.Id, "Confirm your email", string.Format(emailConfirmation, callbackUrl)).ConfigureAwait(false); } } catch (Exception e) { System.Diagnostics.Trace.TraceError("UserInfo update error: " + e.Message); return(BadRequest("Something went wrong...")); } return(Ok(new { newEmail, preferences.email })); }
public async Task <ActionResult> UserPreferences([Bind(Include = "Disable_custom_css, Night_mode, OpenLinksInNewTab, Enable_adult_content, Public_subscriptions, Topmenu_from_subscriptions, Shortbio, Avatar")] UserPreferencesViewModel model) { ViewBag.UserName = User.Identity.Name; if (!ModelState.IsValid) { return(View("Manage", model)); } // save changes string newTheme; using (var db = new voatEntities()) { var userPreferences = GetUserPreference(db); // modify existing preferences userPreferences.DisableCSS = model.Disable_custom_css; userPreferences.NightMode = model.Night_mode; userPreferences.OpenInNewWindow = model.OpenLinksInNewTab; userPreferences.EnableAdultContent = model.Enable_adult_content; userPreferences.DisplaySubscriptions = model.Public_subscriptions; userPreferences.UseSubscriptionsMenu = model.Topmenu_from_subscriptions; await db.SaveChangesAsync(); newTheme = userPreferences.NightMode ? "dark" : "light"; } ClearUserCache(); UserHelper.SetUserStylePreferenceCookie(newTheme); return(RedirectToAction("Manage")); }
public async Task<IViewComponentResult> InvokeAsync(int count, Guid? gameId, Guid? userId, Guid? oldestId, DateTime? oldestDate, bool? articlesOnly) { UserPreferencesViewModel preferences = _userPreferencesAppService.GetByUserId(CurrentUserId); ActivityFeedRequestViewModel vm = new ActivityFeedRequestViewModel { CurrentUserId = CurrentUserId, Count = count, GameId = gameId, UserId = userId, Languages = preferences.Languages, OldestId = oldestId, OldestDate = oldestDate, ArticlesOnly = articlesOnly }; List<UserContentViewModel> model = _userContentAppService.GetActivityFeed(vm).ToList(); ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString()); bool userIsAdmin = user != null && await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString()); foreach (UserContentViewModel item in model) { if (item.UserContentType == UserContentType.TeamCreation) { FormatTeamCreationPost(item); } if (item.UserContentType == UserContentType.JobPosition) { FormatJobPositionPostForTheFeed(item); } else { item.Content = ContentHelper.FormatContentToShow(item.Content); } foreach (CommentViewModel comment in item.Comments) { comment.Text = ContentHelper.FormatHashTagsToShow(comment.Text); } item.Permissions.CanEdit = !item.HasPoll && (item.UserId == CurrentUserId || userIsAdmin); item.Permissions.CanDelete = item.UserId == CurrentUserId || userIsAdmin; } if (model.Any()) { UserContentViewModel oldest = model.OrderByDescending(x => x.CreateDate).Last(); ViewData["OldestPostGuid"] = oldest.Id; ViewData["OldestPostDate"] = oldest.CreateDate.ToString("o"); } ViewData["IsMorePosts"] = oldestId.HasValue; ViewData["UserId"] = userId; return await Task.Run(() => View(model)); }
public ActionResult GetUserPreferences() { try { using (var db = new voatEntities()) { var userPreferences = GetUserPreference(db); // load existing preferences and return to view engine var tmpModel = new UserPreferencesViewModel { Disable_custom_css = userPreferences.DisableCSS, Night_mode = userPreferences.NightMode, OpenLinksInNewTab = userPreferences.OpenInNewWindow, Enable_adult_content = userPreferences.EnableAdultContent, Public_subscriptions = userPreferences.DisplaySubscriptions, Topmenu_from_subscriptions = userPreferences.UseSubscriptionsMenu }; return(PartialView("_UserPreferences", tmpModel)); } } catch (Exception) { return(new EmptyResult()); } }
public ActionResult Index() { var tickets = db.Tickets.Include(t => t.AssignedToUser).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } var myUserId = User.Identity.GetUserId(); var ticketlist = db.Tickets.AsQueryable(); var ticketvm = ticketlist.ToList(); ViewBag.StatusAll = false; ViewBag.StatusOpen = false; ViewBag.StatusClosed = false; ViewBag.StatusArchived = false; ViewBag.TicketsAll = false; ViewBag.TicketsMine = false; // First time TempData["UserPreferences"] is setup in a sequence UserPreferencesViewModel prefvm = new UserPreferencesViewModel(); TempData["UserPreferences"] = prefvm; //prefvm.FilterByStatus = "ALL"; prefvm.Tickets = ticketvm; return(View(prefvm)); }
private Tuple <bool, string> SaveContactDetails(UserPreferencesViewModel p) { Tuple <bool, string> result = ValidateInputs(p); if (!result.Item1) { return(result); } _user.mobile = p.Mobile; _user.phone_area_code = p.PhoneAreaCode; _user.phone_number = p.PhoneNumber; _user.fax_area_code = p.FaxAreaCode; _user.fax_number = p.Fax; _user.street1 = p.Address; _user.street2 = p.Address2; _user.suburb = p.Suburb; _user.postcode = p.PostCode; _user.state = p.State; _user.country = p.Country; try { _context.SaveChanges(); return(Tuple.Create(true, "Details updated successfully. ")); } catch (Exception e) { return(Tuple.Create(false, "Failed to update contact details. " + e.ToDetailedString())); } }
public async Task <IActionResult> Languages() { UserPreferencesViewModel vm = userPreferencesAppService.GetByUserId(CurrentUserId); vm.StatusMessage = StatusMessage; return(await Task.Run(() => View(vm))); }
private Tuple <bool, string> ValidateInputs(UserPreferencesViewModel p) { bool result = true; string error = ""; Regex rgx1 = new Regex("[A-Za-z0-9 ]+$"); Regex rgx2 = new Regex("[A-Za-z ]+$"); Regex rgx3 = new Regex("[0-9 ]+$"); try { if (!rgx3.IsMatch(p.Mobile) && p.Mobile.Length > 0) { result = false; error = "Mobile number must only contain numeric characters. "; } if (result && ((!rgx3.IsMatch(p.PhoneAreaCode) && p.PhoneAreaCode.Length > 0) || (!rgx3.IsMatch(p.PhoneNumber) && p.PhoneNumber.Length > 0))) { result = false; error = "Phone number must only contain numeric characters. "; } if (result && ((!rgx3.IsMatch(p.FaxAreaCode) && p.FaxAreaCode.Length > 0) || (!rgx3.IsMatch(p.Fax) && p.Fax.Length > 0))) { result = false; error = "Fax number must only contain numeric characters. "; } if (result && !rgx3.IsMatch(p.PostCode) && p.PostCode.Length > 0) { result = false; error = "Post code must only contain numeric characters. "; } if (result && !rgx2.IsMatch(p.State) && p.State.Length > 0) { result = false; error = "Invalid characters specified for State. "; } if (result && !rgx2.IsMatch(p.Country) && p.Country.Length > 0) { result = false; error = "Invalid characters specified for Country. "; } } catch (Exception e) { result = false; error = "Validation failed for one or more inputs."; } return(new Tuple <bool, string>(result, error)); }
public List <SupportedLanguage> Resolve(UserPreferences source, UserPreferencesViewModel destination, List <SupportedLanguage> destMember, ResolutionContext context) { string[] platforms = (source.ContentLanguages ?? string.Empty) .Split(new Char[] { '|' }); IEnumerable <SupportedLanguage> platformsConverted = platforms.Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), x)); return(platformsConverted.ToList()); }
public ActionResult Index(UserPreferencesViewModel request, int userId) { try { if (ModelState.IsValid) { var existingUserPref = _dbContext.UserPreferences.FirstOrDefault(up => up.UserId == userId); if (existingUserPref != null) { existingUserPref.AgePreferenceRate = request.AgePreferenceRate; existingUserPref.CleanRate = request.CleanRate; existingUserPref.FoodIssuesRate = request.FoodIssuesRate; existingUserPref.KosherKitchenRate = request.KosherKitchenRate; existingUserPref.MaxPriceRange = request.MaxPriceRange; existingUserPref.MinPriceRange = request.MinPriceRange; existingUserPref.PetFriendlyRate = request.PetFriendlyRate; existingUserPref.ReligiousRate = request.ReligiousRate; existingUserPref.SmokeRate = request.SmokeRate; existingUserPref.SocialFormatRate = request.SocialFormatRate; existingUserPref.GeoLocation = new Point(request.Longitude, request.Latitude) { SRID = 4326 }; _dbContext.UserPreferences.Update(existingUserPref); } else { _dbContext.UserPreferences.Add(new UserPreferences { AgePreferenceRate = request.AgePreferenceRate, CleanRate = request.CleanRate, FoodIssuesRate = request.FoodIssuesRate, KosherKitchenRate = request.KosherKitchenRate, MaxPriceRange = request.MaxPriceRange, MinPriceRange = request.MinPriceRange, PetFriendlyRate = request.PetFriendlyRate, ReligiousRate = request.ReligiousRate, SmokeRate = request.SmokeRate, SocialFormatRate = request.SocialFormatRate, UserId = userId }); } _dbContext.SaveChanges(); return(RedirectToAction("Index", "Match", new { UserId = userId })); } } catch (Exception ex) { _logger.LogError("submit UserPreferences failed", ex); } return(View(request)); }
public async Task <ActionResult> UserPreferences([Bind(Include = "Disable_custom_css, Night_mode, OpenLinksInNewTab, Enable_adult_content, Public_subscriptions, Topmenu_from_subscriptions, Shortbio, Avatar")] UserPreferencesViewModel model) { if (!ModelState.IsValid) { return(View("Manage", model)); } // save changes string newTheme; using (var db = new voatEntities()) { var userPreferences = db.UserPreferences.Find(User.Identity.Name); if (userPreferences != null) { // modify existing preferences userPreferences.DisableCSS = model.Disable_custom_css; userPreferences.NightMode = model.Night_mode; userPreferences.OpenInNewWindow = model.OpenLinksInNewTab; userPreferences.EnableAdultContent = model.Enable_adult_content; userPreferences.DisplaySubscriptions = model.Public_subscriptions; userPreferences.UseSubscriptionsMenu = model.Topmenu_from_subscriptions; await db.SaveChangesAsync(); newTheme = userPreferences.NightMode ? "dark" : "light"; } else { // create a new record for this user in userpreferences table var tmpModel = new UserPreference { DisableCSS = model.Disable_custom_css ? true : false, NightMode = model.Night_mode ? true : false, Language = "en", OpenInNewWindow = model.OpenLinksInNewTab ? true : false, EnableAdultContent = model.Enable_adult_content ? true : false, DisplayVotes = false, DisplaySubscriptions = model.Public_subscriptions ? true : false, UseSubscriptionsMenu = model.Topmenu_from_subscriptions, UserName = User.Identity.Name }; db.UserPreferences.Add(tmpModel); await db.SaveChangesAsync(); newTheme = tmpModel.NightMode ? "dark" : "light"; } } UserHelper.SetUserStylePreferenceCookie(newTheme); return(RedirectToAction("Manage")); }
public Tuple <bool, string> SaveUserPreferences(UserPreferencesViewModel p) { Tuple <bool, string> result; result = SaveRegionalSettings(p); if (result.Item1) { result = SaveContactDetails(p); } return(result); }
public async Task <ActionResult> UserPreferences([Bind(Include = "Disable_custom_css, Night_mode, OpenLinksInNewTab, Enable_adult_content, Public_subscriptions, Topmenu_from_subscriptions, Shortbio, Avatar")] UserPreferencesViewModel model) { var newTheme = "light"; // save changes using (var db = new voatEntities()) { var userPreferences = db.Userpreferences.Find(User.Identity.Name); if (userPreferences != null) { // modify existing preferences userPreferences.Disable_custom_css = model.Disable_custom_css; userPreferences.Night_mode = model.Night_mode; userPreferences.Clicking_mode = model.OpenLinksInNewTab; userPreferences.Enable_adult_content = model.Enable_adult_content; userPreferences.Public_subscriptions = model.Public_subscriptions; userPreferences.Topmenu_from_subscriptions = model.Topmenu_from_subscriptions; await db.SaveChangesAsync(); // apply theme change newTheme = userPreferences.Night_mode ? "dark" : "light"; //Session["UserTheme"] = Utils.User.UserStylePreference(User.Identity.Name); } else { // create a new record for this user in userpreferences table var tmpModel = new Userpreference { Disable_custom_css = model.Disable_custom_css, Night_mode = model.Night_mode, Clicking_mode = model.OpenLinksInNewTab, Enable_adult_content = model.Enable_adult_content, Public_subscriptions = model.Public_subscriptions, Topmenu_from_subscriptions = model.Topmenu_from_subscriptions, Username = User.Identity.Name }; db.Userpreferences.Add(tmpModel); await db.SaveChangesAsync(); newTheme = userPreferences.Night_mode ? "dark" : "light"; // apply theme change //Session["UserTheme"] = Utils.User.UserStylePreference(User.Identity.Name); } } //return RedirectToAction("Manage", new { Message = "Your user preferences have been saved." }); Utils.User.SetUserStylePreferenceCookie(newTheme); return(RedirectToAction("Manage")); }
public OperationResultVo <UserPreferencesViewModel> GetById(Guid currentUserId, Guid id) { try { UserPreferences model = userPreferencesDomainService.GetById(id); UserPreferencesViewModel vm = mapper.Map <UserPreferencesViewModel>(model); return(new OperationResultVo <UserPreferencesViewModel>(vm)); } catch (Exception ex) { return(new OperationResultVo <UserPreferencesViewModel>(ex.Message)); } }
private Tuple <bool, string> SaveRegionalSettings(UserPreferencesViewModel p) { Tuple <bool, string> result; result = UpdateLanguage((byte)p.Language); if (result.Item1) { result = UpdateCurrency(p.Currency); if (result.Item1) { result = UpdateUnitOfMeasurement(p.UnitOfMeasurementName); } } return(result); }
private void SetPreferences(ApplicationUser user) { UserPreferencesViewModel preferences = UserPreferencesAppService.GetByUserId(new Guid(user.Id)); if (preferences == null || preferences.Id == Guid.Empty) { RequestCulture requestLanguage = Request.HttpContext.Features.Get <IRequestCultureFeature>().RequestCulture; SupportedLanguage lang = base.SetLanguageFromCulture(requestLanguage.UICulture.Name); SetCookieValue(SessionValues.PostLanguage, lang.ToString(), 7); } else { SetCookieValue(SessionValues.PostLanguage, preferences.UiLanguage.ToString(), 7); SetSessionValue(SessionValues.JobProfile, preferences.JobProfile.ToString()); } }
public ActionResult Index() { //// Phase1 Enhancement: Move UserPreferences TempData to Login, LoginDemo "Account", but hit other problems like, already logged in //// Phase1 Enhancement: TempData["UserPreferences"] is read in at Start of Action //var userPref = (UserPreferencesViewModel)TempData["UserPreferences"]; //if (userPref.FilterByTickets == null || userPref.FilterByStatus == null) // <= this doesn't work if not instantiated //{ // userPref.FilterByTickets = "ALL"; // userPref.FilterByStatus = "ALL"; //} //// Phase2 Enhancement: use UserPreferences db Model to read and save UserPreferences // Current Initial Implementation: First time in TempData["UserPreferences"] is setup UserPreferencesViewModel userPref = new UserPreferencesViewModel(); TempData["UserPreferences"] = userPref; userPref.FilterByTickets = "ALL"; userPref.FilterByStatus = "ALL"; // Set things up at start of Action var myUserId = User.Identity.GetUserId(); // Currently we get all Tickets at start of Action var tickets = db.Tickets.Include(t => t.AssignedToUser).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); var ticketua = tickets.Where(t => t.TicketStatus.Name != "ARCHIVED").ToList(); // Only get all Unarchived Tickets at start of Action var allUnarchived = db.Tickets.Where(t => t.TicketStatus.Name != "ARCHIVED").Count(); ViewBag.AllUnarchived = allUnarchived; var allOpen = db.Tickets.Where(t => t.TicketStatus.Name == "OPEN").Count(); ViewBag.AllOpen = allOpen; var allClosed = db.Tickets.Where(t => t.TicketStatus.Name == "CLOSED").Count(); ViewBag.AllClosed = allClosed; var allArchived = db.Tickets.Where(t => t.TicketStatus.Name == "ARCHIVED").Count(); ViewBag.AllArchived = allArchived; userPref.Tickets = ticketua; TempData["UserPreferences"] = userPref; ViewBag.FilterByTickets = userPref.FilterByTickets; ViewBag.FilterByStatus = userPref.FilterByStatus; return(View(userPref)); }
public async Task <IActionResult> SavePreferences(UserPreferencesViewModel userPreferencesViewModel) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var savedUserPreferences = await _preferencesClient.SaveUserPreferences(userPreferencesViewModel.Id, userId, userPreferencesViewModel.Diet, userPreferencesViewModel.Intolerances, userPreferencesViewModel.MaxCalorie, userPreferencesViewModel.MaxCarb, userPreferencesViewModel.MaxProtein, userPreferencesViewModel.MinProtein); var savedUserPreferencesModel = new UserPreference() { UserId = savedUserPreferences.UserId, Diet = savedUserPreferences.Diet, Intolerances = savedUserPreferences.Intolerances, MaxCalorie = savedUserPreferences.MaxCalorie, MaxCarb = savedUserPreferences.MaxCarb, MaxProtein = savedUserPreferences.MaxProtein, MinProtein = savedUserPreferences.MinProtein, }; return(View(savedUserPreferencesModel)); }
public async Task <ActionResult> Preferences(UserPreferencesViewModel model) { ViewBag.ManageNavigationKey = "Preferences"; if (!ModelState.IsValid) { return(View(model)); } var user = await GetCurrentUserAsync(); user.ShowNsfw = model.ShowNsfw; user.EnableStyles = model.EnableStyles; await _userManager.UpdateAsync(user); AddSuccessMessage("Your preferences have been updated."); return(View(model)); }
public UserPreferencesViewModel GetByUserId(Guid userId) { IEnumerable <UserPreferences> list = userPreferencesDomainService.GetByUserId(userId); UserPreferences model = list.FirstOrDefault(); if (model == null) { model = new UserPreferences { UserId = userId, UiLanguage = SupportedLanguage.English }; } UserPreferencesViewModel vm = mapper.Map <UserPreferencesViewModel>(model); return(vm); }
private void SetLanguage() { PostFromHomeViewModel postModel = new PostFromHomeViewModel(); RequestCulture requestLanguage = Request.HttpContext.Features.Get <IRequestCultureFeature>().RequestCulture; string lang = GetCookieValue(SessionValues.PostLanguage); if (lang != null) { SupportedLanguage langEnum = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), lang); postModel.DefaultLanguage = langEnum; } else { if (!User.Identity.IsAuthenticated) { SetAspNetCultureCookie(requestLanguage); postModel.DefaultLanguage = base.SetLanguageFromCulture(requestLanguage.UICulture.Name); } else { UserPreferencesViewModel userPrefs = userPreferencesAppService.GetByUserId(CurrentUserId); if (userPrefs != null && userPrefs.Id != Guid.Empty) { SetAspNetCultureCookie(userPrefs.UiLanguage); SetCookieValue(SessionValues.PostLanguage, postModel.DefaultLanguage.ToString(), 7); postModel.DefaultLanguage = userPrefs.UiLanguage; } else { SetAspNetCultureCookie(requestLanguage); postModel.DefaultLanguage = base.SetLanguageFromCulture(requestLanguage.UICulture.Name); } } } ViewBag.PostFromHome = postModel; }
public OperationResultVo <Guid> Save(Guid currentUserId, UserPreferencesViewModel viewModel) { try { UserPreferences model; if (viewModel.Id == viewModel.UserId) { viewModel.Id = Guid.Empty; } UserPreferences existing = userPreferencesDomainService.GetById(viewModel.Id); if (existing != null) { model = mapper.Map(viewModel, existing); } else { model = mapper.Map <UserPreferences>(viewModel); } if (viewModel.Id == Guid.Empty) { userPreferencesDomainService.Add(model); viewModel.Id = model.Id; } else { userPreferencesDomainService.Update(model); } unitOfWork.Commit(); return(new OperationResultVo <Guid>(model.Id)); } catch (Exception ex) { return(new OperationResultVo <Guid>(ex.Message)); } }
/// <summary> /// Returns the user preferences for GET. /// </summary> /// <returns></returns> public UserPreferencesViewModel GetUserPreferences() { UserPreferencesViewModel p = new UserPreferencesViewModel(); p.Language = _user.language_auto; p.Currency = _user.currency_auto; p.UnitOfMeasurementName = _user.track_uom; p.Email = _user.email; p.Mobile = _user.mobile; p.PhoneNumber = _user.phone_number; p.PhoneAreaCode = _user.phone_area_code; p.Fax = _user.fax_number; p.FaxAreaCode = _user.fax_area_code; p.Address = _user.street1; p.Address2 = _user.street2; p.Suburb = _user.suburb; p.PostCode = _user.postcode; p.State = _user.state; p.Country = _user.country; return(p); }
public IActionResult SetJobProfile(JobProfile type) { try { if (type == 0) { type = JobProfile.Applicant; } UserPreferencesViewModel userPreferences = UserPreferencesAppService.GetByUserId(CurrentUserId); if (userPreferences == null) { userPreferences = new UserPreferencesViewModel { UserId = CurrentUserId }; } userPreferences.JobProfile = type; OperationResultVo <Guid> saveResult = UserPreferencesAppService.Save(CurrentUserId, userPreferences); if (!saveResult.Success) { return(Json(new OperationResultVo(false, saveResult.Message))); } SetSessionValue(SessionValues.JobProfile, userPreferences.JobProfile.ToString()); string url = Url.Action("Index", "JobPosition", new { area = "Work" }); return(Json(new OperationResultRedirectVo(url, SharedLocalizer["Job Profile set successfully!"]))); } catch (Exception ex) { return(Json(new OperationResultVo(ex.Message))); } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: // At Login Success, TempData["UserPreferences"] is setup // Future Enhancement: use UserPreferences Model to read and save UserPreferences UserPreferencesViewModel prefvm = new UserPreferencesViewModel(); prefvm.FilterByTickets = "ALL"; prefvm.FilterByStatus = "ALL"; TempData["UserPreferences"] = prefvm; ViewBag.FilterByTickets = "ALL"; ViewBag.FilterByStatus = "ALL"; ViewBag.StatusMessage = "Filter By Status: " + ViewBag.FilterByStatus + "; Filter By Tickets: " + ViewBag.FilterByTickets; //return RedirectToLocal(returnUrl); return(RedirectToAction("Index", "Tickets")); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public IActionResult Index(string msg) { string studyProfile = StudyProfile.Student.ToString(); if (User.Identity.IsAuthenticated) { studyProfile = GetSessionValue(SessionValues.StudyProfile); if (string.IsNullOrWhiteSpace(studyProfile)) { UserPreferencesViewModel userPreferences = UserPreferencesAppService.GetByUserId(CurrentUserId); if (userPreferences == null || userPreferences.StudyProfile == 0) { return(View("NoStudyProfile")); } else { SetSessionValue(SessionValues.StudyProfile, userPreferences.StudyProfile.ToString()); studyProfile = userPreferences.StudyProfile.ToString(); } } } ViewData["studyProfile"] = studyProfile; switch (studyProfile) { case "Mentor": return(View("MentorDashboard")); case "Student": return(View("StudentDashboard")); default: return(View("StudentDashboard")); } }