예제 #1
0
        public async Task <OrderInfo> Create(NewOrder order)
        {
            var newOrder = new Order
            {
                CreateDate = DateTime.Now,
                CreatorId  = order.CreatorId,
                Status     = OrderStatus.New,
                IsDeleted  = false,
                OrderItems = new List <OrderItem>()
            };

            newOrder.OrderCode = Guid.NewGuid().ToString();

            _context.Orders.Add(newOrder);
            await _context.SaveChangesAsync();

            newOrder.OrderCode = await _codeGenerator.GenerateAsync(newOrder.Id);

            await _context.SaveChangesAsync();

            return(_mapper.Map <OrderInfo>(newOrder));
        }