public void Create(User newUser) { // if(!_db.Users.Any( a => a.Username == newUser.Username)) // { _db.Users.Add(newUser); _db.SaveChanges(); // } }
public void Post([FromBody] Question newQuestion) { var identity = (ClaimsIdentity)User.Identity; var foundId = identity.FindFirst(ClaimTypes.Name).Value; newQuestion.UserID = Convert.ToInt32(foundId); _db.Questions.Add(newQuestion); _db.SaveChanges(); }
public void Post([FromBody] Answer newAnswer, int id) { var identity = (ClaimsIdentity)User.Identity; var foundId = identity.FindFirst(ClaimTypes.Name).Value; newAnswer.UserId = Convert.ToInt32(foundId); newAnswer.QuestionID = id; _db.Answers.Add(newAnswer); _db.SaveChanges(); }
public void Post([FromBody] User newUser) { _db.Users.Add(newUser); _db.SaveChanges(); }