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; } /// /// Endpoint to return analysis on CancelledSales within a specified period /// /// /// [Authorize] [HttpGet, Route("cancelledsales/{a_start}/{a_end}")] public IEnumerable GetCancelledSalesAsync(DateTime a_start, DateTime a_end) { return m_analyticService.GetCancelledSales(a_start, a_end); } /// /// Endpoint to return analysis on Sales within a specified period /// /// /// [Authorize] [HttpGet, Route("sales/{a_start}/{a_end}")] public IEnumerable GetSalesAsync(DateTime a_start, DateTime a_end) { return m_analyticService.GetSalesTransaction(a_start, a_end); } /// /// Endpoint to return analysis on Sales within a specified period /// [Authorize] [HttpGet, Route("sales/weekly")] public IEnumerable GetWeeklySalesAsync() { return m_analyticService.GetWeeklySalesTransaction().OrderBy(a => a.Date); } /// /// Endpoint to return analysis on in-debt customers /// /// /// [Authorize] [HttpGet, Route("debtors")] public IEnumerable GetInDebtCustomers() { return m_analyticService.GetInDebtCustomers(); } /// /// Endpoint to return analysis on product price changes /// /// /// [Authorize] [HttpGet, Route("pricechanges/{a_start}/{a_end}")] public IEnumerable GetPriceChanges(DateTime a_start, DateTime a_end) { return m_analyticService.GetPriceChanges(a_start, a_end); } /// /// Endpoint to return analysis on sales by employees /// /// /// [Authorize] [HttpGet, Route("employeesales/{a_start}/{a_end}")] public Dictionary> GetEmployeeSales(DateTime a_start, DateTime a_end) { return m_analyticService.GetEmployeeSales(a_start, a_end); } /// /// Endpoint to return analysis on product items low on stock /// /// /// [Authorize] [HttpGet, Route("lowonstock")] public IEnumerable GetLowOnStockItems() { return m_analyticService.GetOutOfStockItems(); } /// /// Endpoint to return analysis on the most purchased product item /// /// /// [Authorize] [HttpGet, Route("mostpurchaseditem/{a_start}/{a_end}")] public IEnumerable GetMostPurchased(DateTime a_start, DateTime a_end) { return m_analyticService.GetMostPurchasedItem(a_start, a_end); } /// /// Endpoint to return analysis on trade summary /// [Authorize] [HttpGet, Route("tradesummary")] public TradeSummary GetTradeSummary() { return m_analyticService.GetTradeSummary(); } /// /// Endpoint to return analysis on trade summary group by categories /// [Authorize] [HttpGet, Route("categorysummary")] public IEnumerable GetCategoryTradeSummary() { return m_analyticService.GetWeeklySalesCategoryTransaction(10); } /// /// Endpoint to return analysis on recent transactions /// [Authorize] [HttpGet, Route("sales/recent/{a_limit}")] public IEnumerable GetRecentTransactions(int a_limit) { return m_analyticService.GetRecentSales(a_limit); } /// /// Endpoint to return analysis on recent price changes /// [Authorize] [HttpGet, Route("pricechanges/recent/{a_limit}")] public IEnumerable GetRecentPricing(int a_limit) { return m_analyticService.GetRecentPriceChanges(a_limit); } /// /// Endpoint to return analysis on product price change history /// [Authorize] [HttpGet, Route("pricechanges/product/history/{a_limit}")] public IEnumerable GetPriceChangeHistory(int a_limit) { return m_analyticService.GetProductPriceChangeHistory(a_limit); } } }