public IActionResult Login(UserViewModel user) { if (ModelState.IsValid) { _credentialsRepository.SetUser(user.ConvertTo()); return(RedirectToAction("Index")); } else { ViewBag.Error = "Please input all fields."; } return(View(user)); }
public IHttpActionResult GetUserFullData(string username) { var wantedUser = this.Data .Users .All() .FirstOrDefault(u => u.UserName == username); if (wantedUser == null) { return(this.NotFound()); } var currentUserId = this.UserIdProvider.GetUserId(); var currentUser = this.Data.Users.Find(currentUserId); UserViewModel viewModel = UserViewModel.ConvertTo(wantedUser, currentUser); return(this.Ok(viewModel)); }