コード例 #1
0
ファイル: DeliveryQueries.cs プロジェクト: sheaft-app/api
        public IQueryable <Delivery> GetAll([ScopedService] QueryDbContext context, CancellationToken token)
        {
            SetLogTransaction();

            if (CurrentUser.IsInRole(_roleOptions.Producer.Value))
            {
                return(context.Set <Delivery>()
                       .Where(c => c.ProducerId == CurrentUser.Id));
            }

            return(context.Set <Delivery>()
                   .Where(c => c.ClientId == CurrentUser.Id));
        }
コード例 #2
0
ファイル: ProductQueries.cs プロジェクト: sheaft-app/api
        public async Task <IQueryable <Batch> > GetProductsBatches([ID(nameof(Product))] IEnumerable <Guid> ids,
                                                                   [ScopedService] QueryDbContext context, CancellationToken token)
        {
            SetLogTransaction();

            var batchIds = new List <Guid>();

            if (CurrentUser.IsInRole(_roleOptions.Producer.Value))
            {
                batchIds = await context.Set <PreparedProduct>()
                           .Where(cp => ids.Contains(cp.ProductId))
                           .SelectMany(cp => cp.Batches.Select(b => b.BatchId))
                           .ToListAsync(token);
            }
            else
            {
                batchIds = await context.PurchaseOrders
                           .Where(po => po.ClientId == CurrentUser.Id)
                           .SelectMany(cp => cp.Picking.PreparedProducts.Where(po => ids.Contains(po.ProductId)).Where(po => po.PurchaseOrderId == cp.Id).SelectMany(po => po.Batches.Select(b => b.BatchId)))
                           .ToListAsync(token);
            }

            batchIds = batchIds.Distinct().ToList();

            return(context.Batches
                   .Where(c => batchIds.Contains(c.Id)));
        }
コード例 #3
0
ファイル: DeliveryQueries.cs プロジェクト: sheaft-app/api
        public IQueryable <Delivery> GetDelivery([ID] Guid id,
                                                 [ScopedService] QueryDbContext context)
        {
            SetLogTransaction(id);

            return(context.Set <Delivery>()
                   .Where(c => c.Id == id));
        }
コード例 #4
0
ファイル: BusinessQueries.cs プロジェクト: sheaft-app/api
 public IQueryable <BusinessClosing> GetAll([ScopedService] QueryDbContext context)
 {
     SetLogTransaction();
     return(context.Set <BusinessClosing>()
            .Where(d => d.BusinessId == CurrentUser.Id && d.ClosedTo > DateTimeOffset.UtcNow));
 }
コード例 #5
0
ファイル: BusinessQueries.cs プロジェクト: sheaft-app/api
 public IQueryable <BusinessClosing> Get([ID] Guid id, [ScopedService] QueryDbContext context)
 {
     SetLogTransaction(id);
     return(context.Set <BusinessClosing>()
            .Where(d => d.Id == id && d.BusinessId == CurrentUser.Id));
 }
コード例 #6
0
ファイル: BusinessQueries.cs プロジェクト: sheaft-app/api
 public IQueryable <BusinessLegal> GetLegals([ScopedService] QueryDbContext context)
 {
     SetLogTransaction();
     return(context.Set <BusinessLegal>()
            .Where(d => d.UserId == CurrentUser.Id));
 }
コード例 #7
0
 public IQueryable <DeliveryClosing> GetClosings([ID] Guid deliveryId, [ScopedService] QueryDbContext context)
 {
     SetLogTransaction(deliveryId);
     return(context.Set <DeliveryClosing>()
            .Where(d => d.DeliveryModeId == deliveryId && d.ClosedTo > DateTimeOffset.UtcNow));
 }
コード例 #8
0
 public IQueryable <DeliveryClosing> GetClosing([ID] Guid id, [ScopedService] QueryDbContext context)
 {
     SetLogTransaction(id);
     return(context.Set <DeliveryClosing>()
            .Where(d => d.Id == id));
 }
コード例 #9
0
 public IQueryable <Catalog> GetAll([ScopedService] QueryDbContext context)
 {
     SetLogTransaction();
     return(context.Set <Domain.Catalog>()
            .Where(c => c.ProducerId == CurrentUser.Id));
 }
コード例 #10
0
 public IQueryable <Catalog> Get([ID] Guid id, [ScopedService] QueryDbContext context)
 {
     SetLogTransaction(id);
     return(context.Set <Domain.Catalog>()
            .Where(c => c.Id == id));
 }