Beispiel #1
0
        internal IReadOnlyCollection <DriverIdDto> MapToDriverInformation(DriverResponse response)
        {
            Guard.Argument(response).NotNull();
            Guard.Argument(response.Drivers).NotNull();

            return(MapDriverIDs(response.Drivers));
        }
Beispiel #2
0
        public async Task <IActionResult> Get(Guid driverId)
        {
            DriverResponse driver = await _db.Drivers.Where(x => x.DriverGuid == driverId)
                                    .Include(x => x.User)
                                    .Select(x => new DriverResponse
            {
                Id                   = x.Id,
                DriverGuid           = x.DriverGuid,
                Address              = x.Address,
                DriverFullName       = x.DriverFullName,
                DrivingLisenceNumber = x.DrivingLisenceNumber,
                MobileNumber         = x.MobileNumber,
                Status               = x.Status,
                UserId               = x.UserId,
                Latitude             = x.User.Latitude,
                Longitude            = x.User.Longitude,
                Username             = x.User.UserName,
                Email                = x.User.Email,
                IsActive             = (bool)x.IsActive
            })
                                    .FirstOrDefaultAsync();

            driver.Orders = GetDriverOrders(driver.Id);

            if (driver != null)
            {
                return(new OkObjectResult(driver));
            }
            throw new Exception("حصل خطأ");
        }
Beispiel #3
0
        public IActionResult RequestUberMe(AuthToken info)
        {
            try
            {
                var            client  = new RestClient("https://api.uber.com/v1/partners/me");
                var            request = new RestRequest(Method.GET);
                DriverResponse dadosMotoristaRetorno = null;

                request.AddHeader("Authorization", string.Format("Bearer {0}", info.access_token));
                request.AddHeader("Accept-Language", "en_US");
                request.AddHeader("Content-Type", "application/json");

                IRestResponse response = client.Execute(request);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    DriverData dadosDoUber = JsonConvert.DeserializeObject <DriverData>(response.Content);

                    dadosMotoristaRetorno = new DriverResponse()
                    {
                        tokenDoMotorista = info.access_token,
                        NomeMotorista    = dadosDoUber.first_name,
                        EmailMotorista   = dadosDoUber.email,
                        UrlFotoMotorista = dadosDoUber.picture
                    };
                }
                else
                {
                    //mock this information, until the liberation of uber's scope
                    dadosMotoristaRetorno = new DriverResponse()
                    {
                        tokenDoMotorista = "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto",
                        NomeMotorista    = "Agostinho Carrara",
                        EmailMotorista   = "*****@*****.**",
                        UrlFotoMotorista = null
                    };
                }

                return(View("Playlist"));
                //return Json(new { StatusCode = HttpStatusCode.OK, RiderProfile = dadosMotoristaRetorno });
            }
            catch (WebException ex)
            {
                var response = ex.Response as HttpWebResponse;

                if (response != null)
                {
                    return(Json(new { StatusCode = (int)response.StatusCode, ex.Message }));
                }
                else
                {
                    return(Json(new { StatusCode = string.Empty, ex.Message }));
                }
            }
        }
Beispiel #4
0
 public static void AddInfoDriver(DriverResponse model)
 {
     id              = model.id;
     number          = model.number;
     lat             = model.lat;
     lng             = model.lng;
     gps_time        = model.gps_time;
     container_count = model.container_count;
     container_state = model.container_state;
     busy            = model.busy;
 }
Beispiel #5
0
        public Task <DriverResponse> GetAll(SearchDriverRequest request, List <int> vehicleTypeIDs)
        {
            var response = new DriverResponse();

            try
            {
                // thieu phuong tien co the lai dc
                var searchDriverModel = new SearchDriverModel
                {
                    Code           = request.Code,
                    Name           = request.Name,
                    PhoneNumber    = request.PhoneNumber,
                    VehicleTypeIDs = string.Join('%', vehicleTypeIDs.OrderBy(x => x)).Length > 0 ? string.Join('%', vehicleTypeIDs.OrderBy(x => x)) : null
                };
                var driverAll = _driverService.GetAll(request.Page, request.PageSize, searchDriverModel);
                var result    = from a in driverAll.Drivers
                                let ids                         = !string.IsNullOrEmpty(a.VehicleTypeIDs) ? a.VehicleTypeIDs.Split(',').ToList() : null
                                                      let empty = String.Empty
                                                                  let cityEmpty = (a.City + a.Country + a.District + a.Street + a.StreetNumber).Length
                                                                                  let address = new
                {
                    City         = a.City,
                    Country      = a.Country,
                    District     = a.District,
                    Street       = a.Street,
                    StreetNumber = a.StreetNumber
                }
                select new
                {
                    DriverInfo = new
                    {
                        Address = cityEmpty > 0 ? address : null,
                        a.Code,
                        DoB = a.DoB.HasValue ? a.DoB.Value.ToString("dd/MM/yyyy", null) : empty,
                        a.IDCardNumber,
                        a.Name,
                        a.Note,
                        a.PhoneNumber,
                        a.Sex,
                        StartDate = a.StartDate.HasValue ? a.StartDate.Value.ToString("dd/MM/yyyy", null) : empty,
                        a.Status,
                        VehicleTypes = ids != null?_vehicleTypeService.GetByIds(ids.Select(int.Parse).ToList()) : new List <VehicleTypeReadModel>()
                    },
                    ID     = a.ID,
                    UserID = a.UserID
                };

                response.Data     = result.ToList();
                response.Success  = true;
                response.Metadata = new ResponseModel.PageResponse
                {
                    Page     = driverAll.PageInfo.Page,
                    PageSize = driverAll.PageInfo.PageSize,
                    Total    = driverAll.PageInfo.Total
                };
                response.Message = "";
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Success = false;
            }
            return(Task.FromResult(response));
        }