public async Task <ResultDto <bool> > Update(EstabelecimentoDto estabelecimentoDto) { var estabelecimentoDtoValidate = new EstabelecimentoDtoValidate(estabelecimentoDto); if (!estabelecimentoDtoValidate.Validate()) { return(await Task.FromResult(ResultDto <bool> .Validation(estabelecimentoDtoValidate.Mensagens))); } var estabelecimento = await _estabelecimentoRepository.ObterPorId(estabelecimentoDto.EstabelecimentoId); estabelecimento.AtualizarEstabelecimento(estabelecimentoDto); await _estabelecimentoRepository.Update(estabelecimento); return(await Task.FromResult(ResultDto <bool> .Success(true))); }
public async Task <ResultDto <EstabelecimentoDto> > Create(EstabelecimentoDto estabelecimentoDto) { var estabelecimentoDtoValidate = new EstabelecimentoDtoValidate(estabelecimentoDto); if (!estabelecimentoDtoValidate.Validate()) { return(await Task.FromResult(ResultDto <EstabelecimentoDto> .Validation(estabelecimentoDtoValidate.Mensagens))); } var estabelecimento = _mapper.Map <Estabelecimento>(estabelecimentoDto); estabelecimento.SituacaoId = (int)ESituacao.ATIVO; estabelecimento.DataCadastro = DateTime.Now; await _estabelecimentoRepository.Create(estabelecimento); return(await Task.FromResult(ResultDto <EstabelecimentoDto> .Success(_mapper.Map <EstabelecimentoDto>(estabelecimento)))); }