* Added required methods to services
This commit is contained in:
@@ -11,6 +11,11 @@ namespace FaKrosnoEfDataModel.Queries
|
|||||||
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailDetails)
|
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailDetails)
|
||||||
.ThenInclude(x => x.ScheduleOrderDetailDetailMiscs).Include(x => x.ScheduleOrderMiscs));
|
.ThenInclude(x => x.ScheduleOrderDetailDetailMiscs).Include(x => x.ScheduleOrderMiscs));
|
||||||
|
|
||||||
|
public static readonly Func<FaKrosnoDbContext, int, IEnumerable<ScheduleOrder?>> GetEntitiesByPurchaser =
|
||||||
|
EF.CompileQuery((FaKrosnoDbContext context, int purchaser) => context.ScheduleOrders
|
||||||
|
.Include(x => x.Recipient).ThenInclude(x => x.Purchaser).Include(x => x.ScheduleOrderDetails)
|
||||||
|
.ThenInclude(x => x.ScheduleOrderDetailMiscs).Where(x => x.Recipient.Purchaser.ID == purchaser));
|
||||||
|
|
||||||
public static readonly Func<FaKrosnoDbContext, DateTime, IEnumerable<ScheduleOrder?>> GetEntitiesByDate =
|
public static readonly Func<FaKrosnoDbContext, DateTime, IEnumerable<ScheduleOrder?>> GetEntitiesByDate =
|
||||||
EF.CompileQuery((FaKrosnoDbContext context, DateTime fromDate) => context.ScheduleOrders
|
EF.CompileQuery((FaKrosnoDbContext context, DateTime fromDate) => context.ScheduleOrders
|
||||||
.Include(x => x.Recipient).ThenInclude(x => x.Purchaser).Include(x => x.ScheduleOrderDetails)
|
.Include(x => x.Recipient).ThenInclude(x => x.Purchaser).Include(x => x.ScheduleOrderDetails)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
{
|
{
|
||||||
Task<IEnumerable<ScheduleOrderDetailDto>?> GetScheduleOrderDetailsAsync(int scheduleOrderId);
|
Task<IEnumerable<ScheduleOrderDetailDto>?> GetScheduleOrderDetailsAsync(int scheduleOrderId);
|
||||||
|
|
||||||
Task<IEnumerable<ScheduleOrderDetailMiscDto>?> GetScheduleOrderDetailMiscsAsync(
|
Task<IEnumerable<ScheduleOrderDetailDetailDto>> GetScheduleOrderDetailsDetailsByIdAsync(
|
||||||
IList<int> scheduleOrderDetailIds, string miscName);
|
int scheduleOrderDetailId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
Task<IEnumerable<ScheduleOrderDto?>> GetEntities();
|
Task<IEnumerable<ScheduleOrderDto?>> GetEntities();
|
||||||
Task<ScheduleOrderDto?> GetById(int id);
|
Task<ScheduleOrderDto?> GetById(int id);
|
||||||
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientId(int recipientId);
|
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientId(int recipientId);
|
||||||
Task<IList<ScheduleOrderDto>> GetByPurchaserId(int purchaserId);
|
Task<IEnumerable<ScheduleOrderDto>> GetByPurchaserId(int purchaserId);
|
||||||
Task<IEnumerable<ScheduleOrderDto?>> GetEntitiesByLastUpdateDate(DateTime date);
|
Task<IEnumerable<ScheduleOrderDto?>> GetEntitiesByLastUpdateDate(DateTime date);
|
||||||
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date);
|
Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
using AutoMapper;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AutoMapper;
|
|
||||||
using AutoMapper.QueryableExtensions;
|
using AutoMapper.QueryableExtensions;
|
||||||
using FaKrosnoEfDataModel.Dtos;
|
using FaKrosnoEfDataModel.Dtos;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -22,10 +17,10 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
.ProjectTo<ScheduleOrderDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
|
.ProjectTo<ScheduleOrderDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ScheduleOrderDetailMiscDto>?> GetScheduleOrderDetailMiscsAsync(IList<int> scheduleOrderDetailIds, string miscName)
|
public async Task<IEnumerable<ScheduleOrderDetailDetailDto>> GetScheduleOrderDetailsDetailsByIdAsync(int scheduleOrderDetailId)
|
||||||
{
|
{
|
||||||
return await Context.ScheduleOrderDetailMiscs.Where(x => x.ID == scheduleOrderDetailIds.First())
|
return await Context.ScheduleOrderDetailDetails.Where(x => x.ScheduleOrderDetailID == scheduleOrderDetailId)
|
||||||
.ProjectTo<ScheduleOrderDetailMiscDto>(Mapper.ConfigurationProvider).ToListAsync();
|
.ProjectTo<ScheduleOrderDetailDetailDto>(Mapper.ConfigurationProvider).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ namespace FaKrosnoEfDataModel.Services
|
|||||||
return scheduleOrders.Where(x => x?.RecipientID == recipientId);
|
return scheduleOrders.Where(x => x?.RecipientID == recipientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IList<ScheduleOrderDto>> GetByPurchaserId(int purchaserId)
|
public async Task<IEnumerable<ScheduleOrderDto>> GetByPurchaserId(int purchaserId)
|
||||||
{
|
{
|
||||||
return await Context.ScheduleOrders.Include(x => x.Recipient).ThenInclude(x => x.Purchaser)
|
IEnumerable<ScheduleOrder?> scheduleOrders =
|
||||||
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailMiscs)
|
(await Task.FromResult(ScheduleOrderQueries.GetEntitiesByPurchaser(Context, purchaserId))).ToList();
|
||||||
.Include(x => x.ScheduleOrderDetails).ThenInclude(x => x.ScheduleOrderDetailDetails)
|
|
||||||
.Where(x => x.Recipient.Purchaser.ID == purchaserId).Select(x => Mapper.Map<ScheduleOrderDto>(x))
|
return scheduleOrders.Select(x => Mapper.Map<ScheduleOrderDto>(x));
|
||||||
.ToListAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date)
|
public async Task<IEnumerable<ScheduleOrderDto?>> GetByRecipientAndLastUpdateDate(int recipientId, DateTime date)
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ public interface IMaterialTransactionService
|
|||||||
{
|
{
|
||||||
Task<IEnumerable<MaterialTransactionDto>> GetAll();
|
Task<IEnumerable<MaterialTransactionDto>> GetAll();
|
||||||
Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber);
|
Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber);
|
||||||
Task<IEnumerable<MaterialTransactionDto?>> GetByWzNumbers(ISet<string> wzNumbers);
|
Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers);
|
||||||
Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber);
|
Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using SytelineSaAppEfDataModel.Dtos;
|
using SytelineSaAppEfDataModel.Dtos;
|
||||||
|
using SytelineSaAppEfDataModel.Entities;
|
||||||
|
|
||||||
namespace SytelineSaAppEfDataModel.Services;
|
namespace SytelineSaAppEfDataModel.Services;
|
||||||
|
|
||||||
@@ -17,17 +18,31 @@ public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper
|
|||||||
.Where(x => x.MTGroupNum == wzNumber)
|
.Where(x => x.MTGroupNum == wzNumber)
|
||||||
.Select(x => mapper.Map<MaterialTransactionDto>(x)).FirstOrDefaultAsync();
|
.Select(x => mapper.Map<MaterialTransactionDto>(x)).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<MaterialTransactionDto?>> GetByWzNumbers(ISet<string> wzNumbers)
|
public async Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers)
|
||||||
{
|
{
|
||||||
return await context.MaterialTransactions
|
if (!wzNumbers.Any())
|
||||||
.Where(x => !string.IsNullOrWhiteSpace(x.MTGroupNum) && wzNumbers.Contains(x.MTGroupNum))
|
return Enumerable.Empty<MaterialTransactionDto>();
|
||||||
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
|
|
||||||
|
var wzNumbersList = string.Join(",", wzNumbers.Select(w => $"'{w}'"));
|
||||||
|
|
||||||
|
var sql = $@"
|
||||||
|
SELECT z.*
|
||||||
|
FROM ZPL_InternalNum_Matltran z
|
||||||
|
WHERE z.MTGroupNum <> ''
|
||||||
|
AND z.MTGroupNum IN ({wzNumbersList})";
|
||||||
|
|
||||||
|
IList<MaterialTransaction> result = await context.MaterialTransactions
|
||||||
|
.FromSqlRaw(sql)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return result.Select(mapper.Map<MaterialTransactionDto>);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber)
|
public async Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber)
|
||||||
{
|
{
|
||||||
return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber)
|
return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber).OrderByDescending(x => x.TransDate)
|
||||||
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
|
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user