public IActionResult Post([FromBody] UserVM userModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var usernameExists = db.Users.Where(u => u.Email == userModel.Email).Count() > 0; if (usernameExists) { return(StatusCode(409, "Username Exists")); } var user = userModel.ToUser(); db.Users.Add(user); db.SaveChanges(); return(CreatedAtRoute("GetUser", new { id = user.Id }, user.ToUserVM())); }