public async Task <OrderPutResponse> PutOne(ApplicationUser currentUser, OrderPutRequest request)
        {
            var response = new OrderPutResponse {
                IsSuccess = false
            };

            if (currentUser is Client)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.NO_RIGHTS_TO_ASSIGN_DRIVER]);
                return(response);
            }

            var order = await _fuelContext.Orders.FirstOrDefaultAsync(x => x.Id == request.OrderId);

            if (order == null)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.ORDER_NOT_FOUND]);
                return(response);
            }

            var driver = await _fuelContext.DriverUsers.FirstOrDefaultAsync(x => x.Id == request.DriverId);

            if (driver == null)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.USER_NOT_FOUND]);
                return(response);
            }

            var lastHistoryRecord = await _fuelContext.StatusHistory
                                    .Where(x => x.OrderId == order.Id)
                                    .OrderByDescending(x => x.ChangeTime)
                                    .FirstOrDefaultAsync();

            if (lastHistoryRecord != null && lastHistoryRecord.Status == Model.Enums.OrderStatus.Completed)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.USER_CAN_NOT_ASSIGN_DRIVER_COMPLETED_ORDER]);
                return(response);
            }

            await _fuelContext.DriverDetalizations.AddAsync(new DriverOrderDetalization
            {
                DriverId    = driver.Id,
                OrderId     = order.Id,
                ReceiptDate = DateTime.Now
            });

            await _fuelContext.SaveChangesAsync();

            // записать в историю, что водитель назначен
            await AddStatusToHistory(order.Id, OrderStatusVM.DriverAssigned);

            response.IsSuccess = true;
            return(response);
        }
        public async Task <OrderPutResponse> PutOne(ApplicationUser currentUser, long orderId, OrderStatusVM status)
        {
            var response = new OrderPutResponse {
                IsSuccess = false
            };

            // данным методом нельзя назначать следующие статусы, для этого есть отдельные методы
            if (status == OrderStatusVM.Created || status == OrderStatusVM.DriverAssigned || status == OrderStatusVM.Paid)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.NO_RIGHTS_TO_ASSIGN_DRIVER]);
                return(response);
            }

            if (currentUser is Driver && status == OrderStatusVM.Cancelled)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.NO_RIGHTS_TO_CANCEL_ORDER]);
                return(response);
            }

            await AddStatusToHistory(orderId, status);

            response.IsSuccess = true;
            return(response);
        }