public IActionResult Post([FromBody] UserLoginAttempt loginAttempt) { if (!ModelState.IsValid) { BadRequest(ModelState); } if (PasswordChecker.PasswordIsValid(loginAttempt)) { var userAccountManager = new UserAccountManager(); var userAccount = userAccountManager.GetByUserName(loginAttempt.UserName); var lastLogin = userAccount.LastLogin; userAccount.LastLogin = DateTime.UtcNow; userAccountManager.Update(userAccount); var timeSpan = userAccount.LastLogin - lastLogin; return(Ok($"Last successful login: {timeSpan.Days} days, {timeSpan.Hours} hours, {timeSpan.Minutes} minutes, and {timeSpan.Seconds} seconds.")); } else { return(Unauthorized()); } }