Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        public IQueryable <Delivery> GetDelivery([ID] Guid id,
                                                 [ScopedService] QueryDbContext context)
        {
            SetLogTransaction(id);

            return(context.Set <Delivery>()
                   .Where(c => c.Id == id));
        }
Ejemplo n.º 4
0
 public IQueryable <BusinessClosing> GetAll([ScopedService] QueryDbContext context)
 {
     SetLogTransaction();
     return(context.Set <BusinessClosing>()
            .Where(d => d.BusinessId == CurrentUser.Id && d.ClosedTo > DateTimeOffset.UtcNow));
 }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
 public IQueryable <BusinessLegal> GetLegals([ScopedService] QueryDbContext context)
 {
     SetLogTransaction();
     return(context.Set <BusinessLegal>()
            .Where(d => d.UserId == CurrentUser.Id));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 8
0
 public IQueryable <DeliveryClosing> GetClosing([ID] Guid id, [ScopedService] QueryDbContext context)
 {
     SetLogTransaction(id);
     return(context.Set <DeliveryClosing>()
            .Where(d => d.Id == id));
 }
Ejemplo n.º 9
0
 public IQueryable <Catalog> GetAll([ScopedService] QueryDbContext context)
 {
     SetLogTransaction();
     return(context.Set <Domain.Catalog>()
            .Where(c => c.ProducerId == CurrentUser.Id));
 }
Ejemplo n.º 10
0
 public IQueryable <Catalog> Get([ID] Guid id, [ScopedService] QueryDbContext context)
 {
     SetLogTransaction(id);
     return(context.Set <Domain.Catalog>()
            .Where(c => c.Id == id));
 }