public IActionResult Answer([FromBody] FormAnswerModel model) { if (formAnswerService.Add(new FormAnswer() { FormId = model.FormId, Answer = model.Answer })) { return(Ok()); } return(BadRequest()); }
public async Task <IActionResult> Answer() { string content; using (var reader = new StreamReader(Request.Body)) { content = await reader.ReadToEndAsync(); } var jsonBody = JsonConvert.DeserializeObject <Dictionary <string, object> >(content); var newAnswer = new FormAnswer() { FormId = Guid.Parse(jsonBody["FormId"] as string), Answer = jsonBody["Answer"] as string }; if (formAnswerService.Add(newAnswer)) { return(Ok()); } return(BadRequest()); }