This commit is contained in:
mmrbnjd
2024-06-18 16:15:17 +03:30
parent 692aa30afe
commit e8c0bed48f
6 changed files with 34 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shared.DTOs;
using System.Net;
using System.Runtime.ConstrainedExecution;
namespace Back.Controllers
{
@@ -156,6 +157,7 @@ namespace Back.Controllers
}
}
}

View File

@@ -1,6 +1,8 @@
using Back.Data.Contracts;
using Back.Data.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Shared.DTOs;
namespace Back.Services
{
@@ -38,5 +40,6 @@ namespace Back.Services
{
return await _invoiceitemRepo.Get(w => w.InvoiceID == invoiceID && w.ID == invoiceitemID && w.invoice.CompanyID == companyID).FirstOrDefaultAsync();
}
}
}

View File

@@ -5,6 +5,7 @@ using Back.Data.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Shared.DTOs;
using System.ComponentModel.Design;
using System.Data.SqlTypes;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
@@ -21,7 +22,7 @@ namespace Back.Services
private readonly IAsyncRepository<User> _RepoUser;
private readonly RepositoryBase<Company> _RepoCompany;
private readonly IAsyncRepository<PermissionPeriod> _RepoPermissionPeriod;
private readonly IAsyncRepository<InvoiceItem> _invoiceitemRepo;
private readonly IAsyncRepository<Customer> _RepoCus;
private readonly IAsyncRepository<Invoice> _RepoInvoice;
private readonly IAsyncRepository<CODItem> _RepoCODItem;
@@ -30,8 +31,10 @@ namespace Back.Services
, IAsyncRepository<User> RepoUser
, IAsyncRepository<PermissionPeriod> RepoPermissionPeriod
, RepositoryBase<Company> repoCompany, IAsyncRepository<Customer> RepoCus
, IAsyncRepository<Invoice> RepoInvoice, IAsyncRepository<CODItem> RepoCODItem)
, IAsyncRepository<Invoice> RepoInvoice, IAsyncRepository<CODItem> RepoCODItem
, IAsyncRepository<InvoiceItem> invoiceitemRepo)
{
_invoiceitemRepo = invoiceitemRepo;
_RepoCus = RepoCus;
_RepoInvoice = RepoInvoice;
_RepoCODItem = RepoCODItem;
@@ -291,6 +294,19 @@ namespace Back.Services
if (lastcus != null)
request.lastActivitiesSevices.Add(lastcus);
#endregion
request.MostInvoicedProduct = await _invoiceitemRepo.Get(w => w.invoice.CompanyID == user.RolUsers.First().CompanyID
&& (w.invoice.invoiceType==InvoiceType.Sale || w.invoice.invoiceType == InvoiceType.BackFrmSale
|| w.invoice.invoiceType == InvoiceType.Repair) && !w.invoice.BillReference.HasValue)
.Include(inc=>inc.cODItem)
.GroupBy(g => g.CODID)
.Select(s => new IdNameByCount<int>{
ID= s.Key,
Title=s.Select(s=>s.sstt).First(),
count =Convert.ToInt32(s.Sum(s => s.am))
}).OrderByDescending(o => o.count)
.ToListAsync();
return request;
}
public async Task<User> UpdateUser(User user)

View File

@@ -17,6 +17,7 @@ namespace Shared.DTOs
public List<AlertDTO> Warning { get; set; } = new List<AlertDTO>();
public List<AlertDTO> Notifications { get; set; } = new List<AlertDTO>();
public List<LastActivitySevice> lastActivitiesSevices { get; set; }=new List<LastActivitySevice>();
public List<IdNameByCount<int>>? MostInvoicedProduct { get; set; }=new List<IdNameByCount<int>>();
}
public class ServiceInDashBoardDTO
{

View File

@@ -15,4 +15,8 @@ namespace Shared.DTOs
{
public int Tax { get; set; }
}
public class IdNameByCount<T> : IdName<T>
{
public int count { get; set; }
}
}

View File

@@ -0,0 +1,6 @@
@using Shared.DTOs
<h3>MostInvoicedProduct</h3>
@code {
[Parameter] public List<IdNameByCount<int>>? model { get; set; }
}