Example #1
0
        public async Task <ICollection <Order> > GetDomainOrdersByStatus(OrderStatus status)
        {
            var ordersStates = await OrderStateService.GetByCurrentStatus(status);

            var ordersIdArray = ordersStates.Select(s => s.OrderId).ToArray();

            return(await DomainOrderService.Get(ordersIdArray));
        }
Example #2
0
        public async Task <Order> CreateOrder(BookingAM booking)
        {
            using (var transaction = await TransactionService.BeginTransaction())
            {
                try
                {
                    var domainCustomer = await CustomerService.GetDomainCustomer(booking.Customer);

                    var domainCargo = await CargoService.CreateDomainCargo(booking.Cargo);

                    var domainBill = await BillService.CreateDomainBill(booking.BillInfo, booking.Basket);

                    var route = await RouteService.GetRoute(booking.RootAddress, booking.Waypoints);

                    var domainRoute = await RouteService.CreateDomainRoute(route);

                    var result = await DomainOrderService.Create(
                        booking.OrderTime,
                        domainCustomer.Id,
                        domainCargo.Id,
                        domainRoute.Id,
                        domainBill.Id);

                    await OrderStateService.New(result.Id);

                    transaction.Commit();

                    return(result);
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }