Пример #1
0
        public async Task <Guid> CreateAsync(Guid userId, OrderType type, CancellationToken ct)
        {
            var newType = new OrderType();
            var change  = newType.CreateWithLog(userId, x =>
            {
                x.Id             = type.Id;
                x.AccountId      = type.AccountId;
                x.Name           = type.Name;
                x.IsDeleted      = type.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;
            });

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

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
Пример #2
0
        public async Task <Guid> CreateAsync(Guid userId, OrderStatus status, CancellationToken ct)
        {
            var newStatus = new OrderStatus();
            var change    = newStatus.CreateWithLog(userId, x =>
            {
                x.Id             = status.Id;
                x.AccountId      = status.AccountId;
                x.Name           = status.Name;
                x.IsDeleted      = status.IsDeleted;
                x.IsFinish       = status.IsFinish;
                x.CreateDateTime = DateTime.UtcNow;
            });

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

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
Пример #3
0
        public async Task <Guid> CreateAsync(Guid userId, Order order, CancellationToken ct)
        {
            var newOrder = new Order();
            var type     = await _storage.OrderTypes.FirstAsync(t => t.Id == order.TypeId, ct);

            var status = await _storage.OrderStatuses.FirstAsync(t => t.Id == order.StatusId, ct);

            var change = newOrder.CreateWithLog(userId, x =>
            {
                x.Id                 = order.Id;
                x.AccountId          = order.AccountId;
                x.TypeId             = order.TypeId;
                x.StatusId           = order.StatusId;
                x.CreateUserId       = userId;
                x.ResponsibleUserId  = order.ResponsibleUserId;
                x.CustomerId         = order.CustomerId;
                x.Name               = order.Name;
                x.StartDateTime      = order.StartDateTime;
                x.EndDateTime        = order.EndDateTime;
                x.Sum                = order.Sum;
                x.SumWithoutDiscount = order.SumWithoutDiscount;
                x.IsDeleted          = order.IsDeleted;
                x.CreateDateTime     = DateTime.UtcNow;
                x.Type               = type;
                x.Status             = status;
                x.AttributeLinks     = order.AttributeLinks.Map(x.Id);
                x.Items              = order.Items.Map(x.Id);
            });

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

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
Пример #4
0
        public async Task CreateAsync(Guid userId, OrderComment comment, CancellationToken ct)
        {
            var newComment = new OrderComment
            {
                Id                = Guid.NewGuid(),
                OrderId           = comment.OrderId,
                CommentatorUserId = userId,
                Value             = comment.Value,
                CreateDateTime    = DateTime.UtcNow
            };

            await _storage.AddAsync(newComment, ct);

            await _storage.SaveChangesAsync(ct);
        }