Beispiel #1
0
        public async Task <IActionResult> SignIn([FromBody] User user)
        {
            try
            {
                var dbUser = await _userBusinessLogic.GetUserAsync(user.Username);

                if (dbUser != null)
                {
                    return(Problem("User with this username already present", null, 501, null, null));
                }

                User userInserted = await _userBusinessLogic.AddUserAsync(user);

                if (userInserted == null)
                {
                    return(Problem("An error occured while try to Sign In..."));
                }

                await _userBusinessLogic.Save();

                return(Ok(JsonConvert.SerializeObject(user)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message + "  " + ex.StackTrace));
            }
        }