public async Task <IActionResult> SignupUser([FromBody] SignupRequest request) { try { if (request != null) { bool emailAvailable = await UserHandler.EmailNotInUse(request.User.Email); if (!emailAvailable) { return(StatusCode(505, new ErrorResponse() { Message = "There is already an account associated with that email address" })); } var user = await UserHandler.InsertUser(request.User, request.Password); CustomerProfile cp = new CustomerProfile(); cp.Birthdate = DateTime.UtcNow; cp.Email = request.User.Email; cp.UserId = user.UserId; var profileUpdated = await ProfileHandler.InsertProfile(cp); if (user == null) { return(Unauthorized()); } Logger.LogWarning("User added"); return(Ok(user)); } return(StatusCode(404)); } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(505, ex.Message)); } }
public async Task <IActionResult> InsertProfileByUserId([FromBody] CustomerProfile profile) { try { if (profile != null) { var profileUpdated = await ProfileHandler.InsertProfile(profile); if (profileUpdated == null) { return(StatusCode(505, "Was not able to create profile.")); } Logger.LogWarning("Profile Found"); return(Ok(profile)); } return(StatusCode(505, "Missing profile data.")); } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(505, ex.Message)); } }