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