public ActionResult Login(UserViewModel user, string returnUrl) { if (ModelState.IsValid) { if (IsValid(user)) { var userRoles = userModel.GetUser(user.UserName).Roles.Select(role => AutoMapper.Mapper.Map <Role>(role)); foreach (var role in userRoles) { if (!Roles.IsUserInRole(user.UserName, role.ToString())) { Roles.AddUserToRole(user.UserName, role.ToString()); } } FormsAuthentication.SetAuthCookie(user.UserName, false); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", "Login data is incorrect!"); } } return(View(user)); }
// GET: api/User/UserName public IHttpActionResult Get(string id) { if (string.IsNullOrEmpty(id)) { return(NotFound()); } var user = AutoMapper.Mapper.Map <User>(userModel.GetUser(id)); if (user == null) { return(NotFound()); } return(Ok(user)); }
public async Task <ActionResult <string> > GetUser(int id) { Console.WriteLine("GetUser"); return(userModel.GetUser(id)); }
public async Task <ActionResult <string> > GetUser(int id) { return(_context.GetUser(id)); }