public async Task <UsuarioDto> LoginAsync(LoginDto loginDto) { if (!await _validator.ValidarLogin(loginDto)) { return(null); } var usuario = await _repository.LoginAsync(loginDto.Login, loginDto.PasswordHash); var dto = usuario?.ToDto(); if (dto != null) { await _serviceCache.SalvarAsync(dto.Id, dto); } return(dto); }
public async Task <ProdutoDto> ObterPorIdAsync(Guid id) { var produtoCache = await _serviceCache.ObterAsync <ProdutoDto, Guid>(id); if (produtoCache != null) { return(produtoCache); } var produto = await _repository.ObterPorIdAsync(id); var dto = produto?.ToDto(); if (dto != null) { await _serviceCache.SalvarAsync(dto.Id, dto); } return(dto); }
public async Task <ComandaDto> ObterPorIdAsync(Guid id) { var comandoCache = await _serviceCache.ObterAsync <ComandaDto, Guid>(id); if (comandoCache != null) { return(comandoCache); } var comanda = await _repository.ObterPorIdAsync(id); var dto = comanda?.ToDto(); if (dto != null) { await _serviceCache.SalvarAsync(dto.Id, dto); } return(dto); }