コード例 #1
0
        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);
        }
コード例 #2
0
        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 }));
        }
コード例 #3
0
        public async Task <ActionResult <Survey> > AddAsync([FromBody] Survey survey)
        {
            var item = await _surveyService.AddAsync(survey);

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = item.Id }, item));
        }