Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create services #58

Merged
merged 11 commits into from
Apr 2, 2024
Prev Previous commit
Next Next commit
Corrected DashboardService
SharifovDeveloper committed Apr 2, 2024
commit 67869240e5beb7e4b5a5c25f4ad93d594d640ec9
14 changes: 6 additions & 8 deletions Inflow.Service/DashboardService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using DiyorMarket.Domain.DTOs.Dashboard;
using DiyorMarket.Domain.Interfaces.Services;
using DiyorMarket.Infrastructure.Persistence;
using Inflow.Domain.DTOs.Dashboard;
using Inflow.Domain.Interfaces.Services;
using Inflow.Infrastructure;
using Microsoft.EntityFrameworkCore;

namespace DiyorMarket.Services;

public class DashboardService : IDashboardService
{
private readonly DiyorMarketDbContext _context;
private readonly InflowDbContext _context;

public DashboardService(DiyorMarketDbContext context)
public DashboardService(InflowDbContext context)
{
_context = context;
}
@@ -20,7 +20,7 @@ public DashboardDto GetDashboard()
var salesByCategory = GetDoughChartData();
var splineChartData = GetSpliteChartData();
var transactions = GetTransactions();

return new DashboardDto(summary, salesByCategory, splineChartData, transactions);
}

@@ -32,13 +32,11 @@ join saleItem in _context.SaleItems on product.Id equals saleItem.ProductId
group saleItem by category.Name into groupedCategories
select new SalesByCategoryDto(groupedCategories.Key, groupedCategories.Count());


return salesByCategory;
}

private Summary GetSummary()
{
//2 month sales
var salesItems = _context.SaleItems
.Where(x => x.Sale.SaleDate.Month >= DateTime.Now.AddMonths(-2).Month)
.AsNoTracking();