Example #1
0
        public void ChangeOrderPaymentType(int orderId, PaymentType paymentType, Employee driver)
        {
            if (driver is null)
            {
                throw new ArgumentNullException(nameof(driver));
            }

            var vodovozOrder = _orderRepository.GetOrder(_unitOfWork, orderId)
                               ?? throw new DataNotFoundException(nameof(orderId), $"Заказ { orderId } не найден");

            if (vodovozOrder.OrderStatus != OrderStatus.OnTheWay)
            {
                throw new InvalidOperationException($"Нельзя изменить тип оплаты для заказа: { orderId }, заказ не в пути.");
            }

            var routeList = _routeListRepository.GetActualRouteListByOrder(_unitOfWork, vodovozOrder);

            if (routeList.Driver.Id != driver.Id)
            {
                _logger.LogWarning($"Водитель {driver.Id} попытался сменить тип оплаты заказа {orderId} водителя {routeList.Driver.Id}");
                throw new InvalidOperationException("Нельзя сменить тип оплаты заказа другого водителя");
            }

            vodovozOrder.PaymentType = paymentType;
            _unitOfWork.Save(vodovozOrder);
            _unitOfWork.Commit();
        }
Example #2
0
 public void OpenRoutedList(Order order)
 {
     if (order.OrderStatus == OrderStatus.NewOrder ||
         order.OrderStatus == OrderStatus.Accepted ||
         order.OrderStatus == OrderStatus.OnLoading
         )
     {
         tdiNavigation.OpenTdiTab <RouteListCreateDlg>(null);
     }
     else if (order.OrderStatus == OrderStatus.OnTheWay ||
              order.OrderStatus == OrderStatus.InTravelList ||
              order.OrderStatus == OrderStatus.Closed
              )
     {
         RouteList routeList = _routedListRepository.GetActualRouteListByOrder(UoW, order);
         if (routeList != null)
         {
             tdiNavigation.OpenTdiTab <RouteListKeepingDlg, RouteList>(null, routeList);
         }
     }
     else if (order.OrderStatus == OrderStatus.Shipped)
     {
         RouteList routeList = _routedListRepository.GetActualRouteListByOrder(UoW, order);
         if (routeList != null)
         {
             tdiNavigation.OpenTdiTab <RouteListClosingDlg, RouteList>(null, routeList);
         }
     }
 }