public async Task <IActionResult> Create([FromBody] CreatePoll request) { request.UserId = GetUserId(); await _mediator.Send(request); return(Ok()); }
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)); }
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)); }
public void test(CreatePoll cmd) { Dispatcher.SendCommand(cmd); }