public async Task <IActionResult> AddSurvey([FromBody] SurveyDTO survey) { if (!ModelState.IsValid) { return(BadRequest() as IActionResult); } var result = await service.AddAsync(survey); return(result != null?Ok(result) as IActionResult : BadRequest() as IActionResult); }
public async Task <ActionResult> Create(string description) { var user = await db.Users.Where(u => u.UserName == security.UserName).FirstAsync(); var guid = Guid.NewGuid(); var survey = new Survey() { Description = description, Owner = user, Id = guid }; await surveys.AddAsync(survey); return(RedirectToRoute("SurveyRoute", new { id = survey.Identifier })); }
public async Task <ActionResult <Survey> > AddAsync([FromBody] Survey survey) { var item = await _surveyService.AddAsync(survey); return(CreatedAtAction(nameof(GetByIdAsync), new { id = item.Id }, item)); }