public async Task <ActionResult> Login(LoginModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, isPersistent : false, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
            {
                ApplicationUser user = AccountQueries.GetCurrentUser(model.Email);
                CultureSetAttribute.SavePreferredCulture(HttpContext.Response, user.PreferredCulture);
                if (Url.IsLocalUrl(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                return(RedirectToAction("Login", "Account"));
            }

            case SignInStatus.Failure:
            default:
            {
                ModelState.AddModelError("", "Invalid login");
                return(View(model));
            }
            }
        }
        public ActionResult UserPreferences()
        {
            ApplicationUser  user        = AccountQueries.GetCurrentUser(User.Identity.Name);
            PreferencesModel preferences = new PreferencesModel()
            {
                cultures = AccountQueries.GetCultures().ToList()
            };

            return(View(preferences));
        }
        public ActionResult DeleteBoard(int?id)
        {
            ApplicationUser user    = AccountQueries.GetCurrentUser(User.Identity.Name);
            bool            success = BoardQueries.DeleteBoard(user, (int)id);

            if (success)
            {
                string boardSuccesfullyDeleted = WebResources.BoardDeleteSuccess;
                return(Json(new { success = true, message = boardSuccesfullyDeleted }));
            }

            string boardDeletionFailed = WebResources.BoardDeleteFailure;

            return(Json(new { success = false, message = boardDeletionFailed }));
        }