Retail_manager/RMWPFInterfaceLibrary/Api/SaleEndPoint.cs

35 lines
873 B
C#
Raw Normal View History

using RMWPFInterfaceLibrary.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace RMWPFInterfaceLibrary.Api
{
public class SaleEndPoint : ISaleEndPoint
{
private IAPIHelper _apiHelper;
public SaleEndPoint(IAPIHelper apiHelper)
{
_apiHelper = apiHelper;
}
public async Task PostSale(SaleModel sale)
{
using (HttpResponseMessage response = await _apiHelper.ApiClient.PostAsJsonAsync("api/Sale", sale))
{
if (response.IsSuccessStatusCode)
{
// Log call
}
else
{
throw new Exception(response.ReasonPhrase);
}
}
}
}
}