예제 #1
0
        public async Task <IActionResult> Create([FromBody] CreatePoll request)
        {
            request.UserId = GetUserId();

            await _mediator.Send(request);

            return(Ok());
        }
예제 #2
0
        public async Task <IActionResult> Create([FromBody] CreatePoll x)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(x));
            }

            var dto = _mapper.Map <DtoPoll>(x);

            dto.Id = 0;

            var result = await _pollService.CreateAsync(dto, UserId);

            if (!result.Succeeded)
            {
                return(UnprocessableEntity());
            }

            return(Ok(result.Result));
        }
예제 #3
0
        public async Task <IActionResult> Update([FromBody] CreatePoll model, [FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity(ModelState));
            }

            var dto = await _pollService.GetById(id);

            if (!dto.Succeeded)
            {
                return(UnprocessableEntity(dto.Errors));
            }

            _mapper.Map(model, dto.Result);
            var updated = await _pollService.UpdateAsync(dto.Result, UserId);

            if (!updated.Succeeded)
            {
                return(UnprocessableEntity(updated.Errors));
            }

            return(Ok(updated.Result));
        }
예제 #4
0
 public void test(CreatePoll cmd)
 {
     Dispatcher.SendCommand(cmd);
 }