Skip to content

Instantly share code, notes, and snippets.

@rahulsahay19
Created January 11, 2021 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulsahay19/d74c1d6e1e822a4e55099eb944185642 to your computer and use it in GitHub Desktop.
Save rahulsahay19/d74c1d6e1e822a4e55099eb944185642 to your computer and use it in GitHub Desktop.
httpClient
using BookMyEvent.Services.ShoppingCart.DTOs;
using BookMyEvent.Services.ShoppingCart.Extensions;
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace BookMyEvent.Services.ShoppingCart.Services
{
public class DiscountService : IDiscountService
{
private readonly HttpClient _httpClient;
public DiscountService(HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<Coupon> GetCoupon(Guid userId)
{
var response = await _httpClient.GetAsync($"/api/discount/user/{userId}");
if (!response.IsSuccessStatusCode)
{
return null;
}
return await response.ReadContentAs<Coupon>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment