Exemple #1
0
        public async Task UpdateAsync(Guid userId, Order oldOrder, Order newOrder, CancellationToken ct)
        {
            var change = oldOrder.UpdateWithLog(userId, x =>
            {
                x.AccountId         = newOrder.AccountId;
                x.TypeId            = newOrder.TypeId;
                x.StatusId          = newOrder.StatusId;
                x.ResponsibleUserId = newOrder.ResponsibleUserId;
                x.CustomerId        = newOrder.CustomerId;
                x.Name               = newOrder.Name;
                x.StartDateTime      = newOrder.StartDateTime;
                x.EndDateTime        = newOrder.EndDateTime;
                x.Sum                = newOrder.Sum;
                x.SumWithoutDiscount = newOrder.SumWithoutDiscount;
                x.IsDeleted          = newOrder.IsDeleted;
                x.ModifyDateTime     = DateTime.UtcNow;
                x.AttributeLinks     = newOrder.AttributeLinks.Map(x.Id);
                x.Items              = newOrder.Items.Map(x.Id);
            });

            _storage.Update(oldOrder);
            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);
        }
Exemple #2
0
        public async Task UpdateAsync(
            Guid userId,
            OrderType oldType,
            OrderType newType,
            CancellationToken ct)
        {
            var change = oldType.UpdateWithLog(userId, x =>
            {
                x.Name           = newType.Name;
                x.IsDeleted      = newType.IsDeleted;
                x.ModifyDateTime = DateTime.UtcNow;
            });

            _storage.Update(oldType);
            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);
        }
Exemple #3
0
        public async Task UpdateAsync(
            Guid userId,
            OrderAttribute oldAttribute,
            OrderAttribute newAttribute,
            CancellationToken ct)
        {
            var change = oldAttribute.UpdateWithLog(userId, x =>
            {
                x.Type           = newAttribute.Type;
                x.Key            = newAttribute.Key;
                x.IsDeleted      = newAttribute.IsDeleted;
                x.ModifyDateTime = DateTime.UtcNow;
            });

            _storage.Update(oldAttribute);
            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);
        }
        public async Task UpdateAsync(
            Guid userId,
            OrderStatus oldStatus,
            OrderStatus newStatus,
            CancellationToken ct)
        {
            var change = oldStatus.UpdateWithLog(userId, x =>
            {
                x.Name           = newStatus.Name;
                x.IsDeleted      = newStatus.IsDeleted;
                x.IsFinish       = newStatus.IsFinish;
                x.ModifyDateTime = DateTime.UtcNow;
            });

            _storage.Update(oldStatus);
            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);
        }
Exemple #5
0
        public void Save()
        {
            try
            {
                _validator.Validate();
                if (_order.Id == -1)
                {
                    _order.Id = _nextId++;
                    _storage.Add(_order);
                    ResetOrderInstance();
                }
                else
                {
                    _storage.Update(_order.Id, _order);
                }

                Util.Info("Wpf_Service", "An order was saved successfully!");
            }
            catch (Exception exc)
            {
                Util.Error("Order error", exc.Message);
            }
        }