Esempio n. 1
0
        public async Task <Guid> CreateAsync(Guid userId, StockBalance balance, CancellationToken ct)
        {
            var newStockBalance = new StockBalance();

            var change = newStockBalance.CreateWithLog(userId, x =>
            {
                x.Id             = balance.Id;
                x.AccountId      = balance.AccountId;
                x.CreateUserId   = userId;
                x.RoomId         = balance.RoomId;
                x.ProductId      = balance.ProductId;
                x.Count          = balance.Count;
                x.IsDeleted      = balance.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;

                // x.UniqueElementIds = balance.UniqueElementIds;
            });

            var entry = await _storage.AddAsync(newStockBalance, ct);

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
Esempio n. 2
0
        public async Task <Guid> CreateAsync(Guid userId, StockArrival arrival, CancellationToken ct)
        {
            var newStockArrival = new StockArrival();

            var change = newStockArrival.CreateWithLog(userId, x =>
            {
                x.Id             = arrival.Id;
                x.AccountId      = arrival.AccountId;
                x.CreateUserId   = userId;
                x.Type           = arrival.Type;
                x.SupplierId     = arrival.SupplierId;
                x.OrderId        = arrival.OrderId;
                x.InventoryId    = arrival.InventoryId;
                x.IsDeleted      = arrival.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;
                x.Items          = arrival.Items.Map(x.Id);
            });

            var entry = await _storage.AddAsync(newStockArrival, ct);

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
Esempio n. 3
0
        public async Task <Guid> CreateAsync(Guid userId, StockRoom room, CancellationToken ct)
        {
            var newRoom = new StockRoom();
            var change  = newRoom.CreateWithLog(userId, x =>
            {
                x.Id             = room.Id;
                x.AccountId      = room.AccountId;
                x.Name           = room.Name;
                x.IsDeleted      = room.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;
            });

            var entry = await _storage.AddAsync(newRoom, ct);

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
        public async Task <Guid> CreateAsync(Guid userId, StockConsumption consumption, CancellationToken ct)
        {
            var newStockConsumption = new StockConsumption();

            var change = newStockConsumption.CreateWithLog(userId, x =>
            {
                x.Id             = consumption.Id;
                x.AccountId      = consumption.AccountId;
                x.CreateUserId   = userId;
                x.Type           = consumption.Type;
                x.OrderId        = consumption.OrderId;
                x.IsDeleted      = consumption.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;
                x.Items          = consumption.Items.Map(x.Id);
            });

            var entry = await _storage.AddAsync(newStockConsumption, ct);

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }