public async Task <Unit> Handle(CreateOrderCommand createOrderRequest, CancellationToken cancellationToken) { var productsToOrder = await _productsRepository.GetAsync(createOrderRequest.ProductsIds, cancellationToken); var order = Order.Create(productsToOrder); await _ordersRepository.CreateAsync(order, cancellationToken); return(Unit.Value); }
private async void AddedToOrderDb(string userId) { User userDB = new User { UserId = userId }; await _ordersRepository.CreateAsync(userDB); await _unitOfWork.CompleteAsync(); }
public async Task <OrderApiDTO> Handle( [NotNull] CreateNewOrderCommand request, CancellationToken cancellationToken) { Guard.NotNull(request, nameof(request)); var newOrder = _mapper.Map <OrderDTO>(request.NewOrder); await _ordersRepository.CreateAsync(newOrder, cancellationToken); var newOrderDto = await _ordersRepository.GetByIdAsync( newOrder.Id, cancellationToken); return(_mapper.Map <OrderApiDTO>(newOrderDto)); }
public async Task CreateAsync(Guid id, Guid customerId, long number, IEnumerable <Guid> productIds, decimal totalAmount, string currency) { var order = new Order(id, customerId, number, productIds, totalAmount, currency); await _ordersRepository.CreateAsync(order); }
public async Task HandleAsync(OrderCreated @event, ICorrelationContext context) { var order = await _ordersService.GetByIdAsync(@event.Id); await _ordersRepository.CreateAsync(order); }
public async Task SaveAsync(CreateOrderDto order) { await _ordersRepository.CreateAsync(order.Adapt <Order>()); }