public async Task <Result <Order> > SaveAsync(Order aggregate) { await _ordersDbContext.Orders.AddAsync(aggregate); await _ordersDbContext.SaveChangesAsync(); return(Result.Ok(aggregate)); }
public async Task <OrderInfo> Create(NewOrder order) { var newOrder = new Order() { //Id = ++i, CreateDate = DateTime.Now, Status = OrderStatus.New, IsDeleted = false, OrderDetails = order.OrderDetails, CreatorId = order.CreatorId }; newOrder.OrderCode = await _codeGeneratorService.GetCode(newOrder.Id); _orderDbContext.Orders.Add(newOrder); _orderDbContext.SaveChangesAsync(); return(_mapper.Map <OrderInfo>(newOrder)); }