public async Task SetCollectorMaskCapacity(Guid collectorId, int newCapacity)
        {
            using (var context = new MasksUnleachedContext())
            {
                var collector = await context.CollectorUsers.FindAsync(collectorId);

                collector.MaskStorageCapacity = newCapacity;
                context.Update(collector);

                await context.SaveChangesAsync();
            }
        }
示例#2
0
        public async Task AddRecyclingOrder(Guid recyclerId, [NotNull] RecyclingOrder recyclingOrder)
        {
            await using var context = new MasksUnleachedContext();
            var recycler = await context.RecyclerUsers.FindAsync(recyclerId);

            if (recycler.RecyclingOrders == null)
            {
                recycler.RecyclingOrders = new Collection <RecyclingOrder>();
            }
            recycler.RecyclingOrders.Add(recyclingOrder);

            context.Update(recycler);
            await context.SaveChangesAsync();
        }
        public async Task AddMaskReception(Guid collectorId, DirtyMaskReception dirtyMaskReception)
        {
            using (var context = new MasksUnleachedContext())
            {
                var collector = await context.CollectorUsers.FindAsync(collectorId);

                if (collector.DirtyMasksReceptions == null)
                {
                    collector.DirtyMasksReceptions = new List <DirtyMaskReception>(1);
                }
                collector.DirtyMasksReceptions.Add(dirtyMaskReception);
                context.Update(collector);

                await context.SaveChangesAsync();
            }
        }