public async Task<ActionResult> Login(LoginViewModel model)
 {
     if (ValidateUserLogin(model))
     {
         FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
         return RedirectToAction("Index", "Home");
     }
     // If we got this far, something failed, redisplay form
     return View(model);
 }
        /// <summary>
        /// Validates the user login.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>an indication about if the user is correctly logged in</returns>
        private bool ValidateUserLogin(LoginViewModel model)
        {
            var encryptOperations = new Encryption();
            var userResult = _crmUserRepository.GetSingle(where: new { UserName = model.UserName });
            if (userResult == null)
            {
                return false;
            }

            return userResult.Password == encryptOperations.Encrypt(model.Password, userResult.Salt);
        }