コード例 #1
0
        public void DeleteOrder(int orderId)
        {
            _logger.LogInformation("Deleting order with ID {orderId}", orderId);

            Entities.OrderHistory entity = _dbContext.OrderHistory.Find(orderId);
            _dbContext.OrderHistory.Remove(entity);
        }
コード例 #2
0
        public void UpdateOrder(Domain.Models.OrderHistory order)
        {
            _logger.LogInformation("Updating order with ID {orderId}", order.OrderId);

            Entities.OrderHistory currentEntity = _dbContext.OrderHistory.Find(order.OrderId);
            Entities.OrderHistory newEntity     = new Entities.OrderHistory
            {
                CustomerName = order.CustomerName,
                CustomerId   = order.CustomerId,
                Location     = order.Location,
                StoreId      = order.StoreId,
                //DateTime = order.DateTime,
                Order      = order.Order,
                TotalPrice = order.TotalPrice
            };

            _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity);
        }
コード例 #3
0
        public void AddOrder(Domain.Models.OrderHistory order)
        {
            if (order.OrderId != 0)
            {
                _logger.LogWarning("Order to be added has an ID ({orderId}) already: ignoring.", order.OrderId);
            }

            _logger.LogInformation("Placing order.");

            Entities.OrderHistory newEntity = new Entities.OrderHistory
            {
                CustomerName = order.CustomerName,
                CustomerId   = order.CustomerId,
                Location     = order.Location,
                StoreId      = order.StoreId,
                DateTime     = DateTime.Now,
                Order        = order.Order,
                TotalPrice   = order.TotalPrice,
            };

            _dbContext.OrderHistory.Add(newEntity);
            _dbContext.SaveChanges();
        }