public async Task <Result <Chamado> > Novo(Chamado Chamado) { return(await ProcessmentCommand.Execute(async() => { var Erros = new List <string>(); var Solicitante = new Usuario { Id = Convert.ToInt32(Principal.GetClaim("Id")) }; Chamado.Solicitante = await UsuarioRepository.GetById(Solicitante); Chamado.Servico = await ServicoRepository.GetById(Chamado.Servico); Chamado.ChamadoPrincipal = await Repository.GetById(Chamado.ChamadoPrincipal); Erros.AddRange(Chamado.IsValid()); if (Erros.Count > 0) { throw new ValidationException(Chamado, Erros.ToArray()); } await Repository.Insert(Chamado); return Chamado; })); }
public virtual async Task <Result <UsuarioViewModel> > ConsultarPorId(int Id) { return(await ProcessmentCommand.Execute(async() => Mapper.Map <UsuarioViewModel>(await Repository.GetById(new Usuario { Id = Id })))); }