public ActionResult LogIn(LogInUser logInUser)
        {
            if (ModelState.IsValid)
            {
                _authProvider.LogIn(logInUser);
                return RedirectToAction("Index", "Home");
            }

            return View(logInUser);
        }
 public void LogIn(LogInUser logInUser)
 {
     var result = AsyncHelpers.RunSync(() => _logInStrategy.LogIn(logInUser.Username, logInUser.Password));
     switch (result.Result)
     {
         case LoginResultType.LoginOk:
             HttpContext.Current.Session[LogInStatusSessionValueName] = true;
             HttpContext.Current.Session[LoggedUserSessionValueName] = logInUser.Username;
             HttpContext.Current.Session[TokenSessionValueName] = result.Token;
             break;
         case LoginResultType.LoginFailed:
             throw new Exception("Wrong username or password.");
         case LoginResultType.ConnectionError:
             throw new Exception("There are some problms now. Please try later.");
         default:
             throw new ArgumentOutOfRangeException();
     }
 }