Ejemplo n.º 1
0
 /// <summary>
 /// The login.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public LoginResponse Login(LoginModel model)
 {
     var user = this.userRepository.Find(profile => profile.Password == model.Password && profile.UserName == model.UserName);
     return new LoginResponse
                {
                    UserId = user.UserId,
                    Company = user.Company.CompanyName,
                    CompanyId = user.CompanyId,
                    UserName = user.UserName,
                    Role = user.Role.RoleName,
                    PreferredLanguage = "en-US"
                };
 }
Ejemplo n.º 2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (this.ModelState.IsValid)
            {
                var response = this.Client.PostAsJsonAsync("/api/account/Login", model).Result;
                var user = response.Content.ReadAsAsync<LoginResponse>().Result;
                this.Session["UserDetail"] = user;
                return this.RedirectToAction("Index", "Products");
            }

            // If we got this far, something failed, redisplay form
            this.ModelState.AddModelError(string.Empty, "The user name or password provided is incorrect.");
            return this.View(model);
        }