public async Task <IActionResult> SetQuestionProfile(QuestionAndAnswer quest) { if (ModelState.IsValid) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); _db.questionAndAnswers.Add(quest); _db.SaveChanges(); return(Ok(quest)); } return(BadRequest(ModelState)); }
public async Task <IActionResult> SetSub(Subscription model) { if (ModelState.IsValid) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); model.User = user; _db.subscriptions.Add(model); _db.SaveChanges(); model.User = null; return(Ok(model)); } return(BadRequest(ModelState)); }