public RetornoGlobal <ButtonsMenuModel> PostMenu(CreateMenuCommand parameter) { RetornoGlobal <ButtonsMenuModel> retorno = new RetornoGlobal <ButtonsMenuModel>(); try { CreateMenuValidator validacao = new CreateMenuValidator(contexto); var result = validacao.Validate(parameter); if (result.IsValid) { ButtonsMenuModel registro = new ButtonsMenuModel() { description = parameter.description, href = parameter.href }; contexto.TabelaButtonsMenu.Add(registro); contexto.SaveChanges(); retorno.status = true; retorno.RetornoObjeto = registro; } else { retorno.status = false; result.Errors.ToList().ForEach(r => retorno.errors.Add(r.ToString()) ); } } catch (Exception e) { retorno.status = false; retorno.errors.Append(e.Message); retorno.errors.Append(e.InnerException.ToString()); } return(retorno); }
public async Task <ActionResult <MenuDto> > Create(CreateMenuCommand command) { return(Ok(await Mediator.Send(command))); }
public async Task <ActionResult <HandleResultDto> > Put([FromBody] CreateMenuCommand cmd) { var response = await _mediator.Send(cmd, HttpContext.RequestAborted); return(response); }