using Biskilog_Accounting.Shared.CustomModels ;
using Biskilog_Accounting.Shared.Interfaces ;
using Biskilog_Accounting.Shared.POSModels ;
using Microsoft.AspNetCore.Authorization ;
using Microsoft.AspNetCore.Mvc ;
using Microsoft.Net.Http.Headers ;
using NuGet.Common ;
namespace Biskilog_Accounting.Server.Controllers
{
[Route("api/[controller] ")]
[ApiController]
public class AnalyticsController : ControllerBase
{
private readonly IAnalytics m_analyticService ;
public AnalyticsController ( IAnalytics a_analytics )
{
m_analyticService = a_analytics ;
}
/// <summary>
/// Endpoint to return analysis on CancelledSales within a specified period
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("cancelledsales/{a_start}/{a_end}")]
public IEnumerable < CancelledSales > GetCancelledSalesAsync ( DateTime a_start , DateTime a_end )
{
return m_analyticService . GetCancelledSales ( a_start , a_end ) ;
}
/// <summary>
/// Endpoint to return analysis on Sales within a specified period
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("sales/{a_start}/{a_end}")]
public IEnumerable < Tblcart > GetSalesAsync ( DateTime a_start , DateTime a_end )
{
return m_analyticService . GetSalesTransaction ( a_start , a_end ) ;
}
/// <summary>
/// Endpoint to return analysis on Sales within a specified period
/// </summary>
[Authorize]
[HttpGet, Route("sales/weekly")]
public IEnumerable < WeeklySaleItem > GetWeeklySalesAsync ( )
{
return m_analyticService . GetWeeklySalesTransaction ( ) . OrderBy ( a = > a . Date ) ;
}
/// <summary>
/// Endpoint to return analysis on in-debt customers
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("debtors")]
public IEnumerable < CustomerAccounts > GetInDebtCustomers ( )
{
return m_analyticService . GetInDebtCustomers ( ) ;
}
/// <summary>
/// Endpoint to return analysis on product price changes
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("pricechanges/{a_start}/{a_end}")]
public IEnumerable < ProductPriceChange > GetPriceChanges ( DateTime a_start , DateTime a_end )
{
return m_analyticService . GetPriceChanges ( a_start , a_end ) ;
}
/// <summary>
/// Endpoint to return analysis on sales by employees
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("employeesales/{a_start}/{a_end}")]
public Dictionary < string , List < SaleItem > > GetEmployeeSales ( DateTime a_start , DateTime a_end )
{
return m_analyticService . GetEmployeeSales ( a_start , a_end ) ;
}
/// <summary>
/// Endpoint to return analysis on product items low on stock
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("lowonstock")]
public IEnumerable < ProductItem > GetLowOnStockItems ( )
{
return m_analyticService . GetOutOfStockItems ( ) ;
}
/// <summary>
/// Endpoint to return analysis on the most purchased product item
/// </summary>
/// <param name="a_start"></param>
/// <param name="a_end"></param>
[Authorize]
[HttpGet, Route("mostpurchaseditem/{a_start}/{a_end}")]
public IEnumerable < MostPurchasedItem > GetMostPurchased ( DateTime a_start , DateTime a_end )
{
return m_analyticService . GetMostPurchasedItem ( a_start , a_end ) ;
}
/// <summary>
/// Endpoint to return analysis on trade summary
/// </summary>
[Authorize]
[HttpGet, Route("tradesummary")]
public TradeSummary GetTradeSummary ( )
{
return m_analyticService . GetTradeSummary ( ) ;
}
/// <summary>
/// Endpoint to return analysis on trade summary group by categories
/// </summary>
[Authorize]
[HttpGet, Route("categorysummary")]
public IEnumerable < WeeklyCategorySummary > GetCategoryTradeSummary ( )
{
return m_analyticService . GetWeeklySalesCategoryTransaction ( 1 0 ) ;
}
/// <summary>
/// Endpoint to return analysis on recent transactions
/// </summary>
[Authorize]
[HttpGet, Route("sales/recent/{a_limit}")]
public IEnumerable < SaleItem > GetRecentTransactions ( int a_limit )
{
return m_analyticService . GetRecentSales ( a_limit ) ;
}
/// <summary>
/// Endpoint to return analysis on recent price changes
/// </summary>
[Authorize]
[HttpGet, Route("pricechanges/recent/{a_limit}")]
public IEnumerable < ProductPriceChange > GetRecentPricing ( int a_limit )
{
return m_analyticService . GetRecentPriceChanges ( a_limit ) ;
}
/// <summary>
/// Endpoint to return analysis on product price change history
/// </summary>
[Authorize]
[HttpGet, Route("pricechanges/product/history/{a_limit}")]
public IEnumerable < ProductPriceChange > GetPriceChangeHistory ( int a_limit )
{
return m_analyticService . GetProductPriceChangeHistory ( a_limit ) ;
}
}
}