public async Task <IActionResult> PutQuestions([FromRoute] int id, [FromBody] Questions questions) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != questions.Id) { return(BadRequest()); } _context.Entry(questions).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostQuestionsAnswer([FromBody] IEnumerable <Answer> answer) { foreach (var item in answer) { _context.Answers.Add(item); await _context.SaveChangesAsync(); } return(Ok()); }
public async Task <IActionResult> PostClient([FromBody] Client client) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Clients.Add(client); await _context.SaveChangesAsync(); return(CreatedAtAction("GetClient", new { id = client.Id }, client)); }