public async Task <Merchant> GetAsync(int id) { var merchant = await CacheService.GetAsync <Merchant>(id.ToString()); if (merchant != null) { return(merchant); } merchant = await MerchantRepository.GetAsync(id); if (merchant != null) { await CacheService.SetAsync(merchant.Id.ToString(), merchant); } return(merchant); }
public async Task <Merchant> UpdateAsync(int id, UpdateMerchantRequestMessage updateMerchantRequestMessage) { var merchant = await MerchantRepository.GetAsync(id); if (merchant == null) { return(null); } merchant.ChangeDocument(updateMerchantRequestMessage.Document); merchant.ChangeName(updateMerchantRequestMessage.Name); if (!await MerchantRepository.UpdateAsync(merchant)) { throw new Exception($"Erro on update merchant"); } await CacheService.DelAsync(id.ToString()); return(merchant); }