Example #1
0
 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));
 }
Example #2
0
        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));
        }