예제 #1
0
 public IHttpActionResult UpdateCurrentDriverLocation()
 {
     try
     {
         var updateDriverCurrentLocation = new UpdateDriverCurrentLocation
         {
             DriverID         = HeaderValueByKey("DRIVERID"),
             AUTH_TOKEN       = HeaderValueByKey("AUTH_TOKEN"),
             CurrentLatitude  = Convert.ToDecimal(HeaderValueByKey("LATITUDE")),
             CurrentLongitude = Convert.ToDecimal(HeaderValueByKey("LONGITUDE")),
             IsLogIn          = true,
             IsOnDuty         = true
         };
         var result = new DriverActivityBO().UpdateCurrentDriverLocation(updateDriverCurrentLocation);
         if (result)
         {
             return(Ok(new { Status = UTILITY.SUCCESSMESSAGE }));
         }
         else
         {
             return(Ok(new { Status = UTILITY.FAILEDMESSAGE }));
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #2
0
        public IHttpActionResult DriverLatestFiveLatlong()
        {
            var DriverID   = HeaderValueByKey("DRIVERID");
            var AUTH_TOKEN = HeaderValueByKey("AUTH_TOKEN");
            var latlongs   = new DriverActivityBO().GetFiveLatLongsforDriver(DriverID, AUTH_TOKEN).TrimEnd('|');
            var result     = GetLatLongsValues(latlongs);

            return(Ok(new { result }));
        }
예제 #3
0
        public IHttpActionResult driverlatestfivelatlong()
        {
            var driverid   = HeaderValueByKey("DRIVERID");
            var auth_token = HeaderValueByKey("AUTH_TOKEN");
            var latlongs   = new DriverActivityBO().GetFiveLatLongsforDriver(driverid, auth_token).TrimEnd('|');
            var result     = GetLatLongsValues(latlongs);

            return(Ok(new { result }));
        }
예제 #4
0
 public IHttpActionResult SaveDriverActivity(DriverActivity driverActivity)
 {
     try
     {
         var result = new DriverActivityBO().SaveDriverActivity(driverActivity);
         return(Ok(result ? UTILITY.SUCCESSMSG : UTILITY.FAILEDMSG));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #5
0
        public IHttpActionResult IsConfirmBooking(string bookingNo)
        {
            try
            {
                var booking = new BookingBO().GetBooking(new Booking
                {
                    BookingNo = bookingNo
                });

                var driverInfo     = new Driver();
                var driverActivity = new DriverActivity();
                if (booking.IsConfirm)
                {
                    driverInfo = new DriverBO().GetDriver(new Driver {
                        DriverID = booking.DriverID
                    });
                    driverActivity = new DriverActivityBO().GetDriverActivityByDriverID(new DriverActivity {
                        DriverID = booking.DriverID
                    });
                }

                if (booking != null)
                {
                    return(Ok(new
                    {
                        isConfirm = booking.IsConfirm,
                        driverId = driverInfo.DriverID ?? "",
                        vehicleNo = driverInfo.VehicleNo ?? "",
                        driverName = driverInfo.DriverName ?? "",
                        driverImage = "",
                        MobileNo = driverInfo.MobileNo ?? "",
                        latitude = driverActivity.CurrentLat,
                        longitude = driverActivity.CurrentLong,
                        OTP = booking.OTP,
                        VehicleType = booking.VehicleType
                    }));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #6
0
        public IHttpActionResult GetDriverGeoPosition(string driverID)
        {
            try
            {
                var driverActivity = new DriverActivityBO().GetDriverActivityByDriverID(new DriverActivity {
                    DriverID = driverID
                });

                return(Ok(new {
                    CurrentLat = driverActivity.CurrentLat,
                    CurrentLong = driverActivity.CurrentLong
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #7
0
 public IHttpActionResult DriverActivities()
 {
     try
     {
         var activities = new DriverActivityBO().GetList();
         if (activities != null)
         {
             return(Ok(activities));
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #8
0
        private TrackCRNVm GetData(string trackCrnNo)
        {
            var booking = new BookingBO().GetByBookingNo(trackCrnNo);
            DriverMonitorInCustomer driverMonitorInCustomer = null;

            if (booking != null && !booking.IsComplete && booking.IsConfirm && !booking.IsCancel)
            {
                driverMonitorInCustomer = new DriverActivityBO().GetDriverMonitorInCustomer(new DriverMonitorInCustomer {
                    DriverId = booking.DriverId
                });
            }

            TrackCRNVm obj = new TrackCRNVm
            {
                booking = booking,
                driverMonitorInCustomer = driverMonitorInCustomer
            };

            return(obj);
        }
예제 #9
0
 public IHttpActionResult DriverMonitorInCustomer(string DriverID)
 {
     try
     {
         var driverMonitorList = new DriverActivityBO().GetDriverMonitorInCustomer(new DriverMonitorInCustomer {
             DriverID = DriverID
         });
         if (driverMonitorList != null)
         {
             return(Ok(driverMonitorList));
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #10
0
 public IHttpActionResult DriverMonitorInCustomer(string DriverID)
 {
     try
     {
         var driverMonitorList = new DriverActivityBO().GetDriverMonitorInCustomer(new DriverMonitorInCustomer {
             DriverId = DriverID
         });
         if (driverMonitorList != null)
         {
             return(Ok(driverMonitorList));
         }
         else
         {
             return(Ok(new { Status = UTILITY.FAILURESTATUS }));
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #11
0
        public IHttpActionResult DriverLogOut()
        {
            try
            {
                var driverActivity = new DriverActivity
                {
                    DriverId  = HeaderValueByKey("DRIVERID"),
                    TokenNo   = HeaderValueByKey("AUTH_TOKEN"),
                    Latitude  = Convert.ToDecimal(HeaderValueByKey("LATITUDE")),
                    Longitude = Convert.ToDecimal(HeaderValueByKey("LONGITUDE")),
                    IsLogIn   = false,
                    IsOnDuty  = false
                };

                var result = new DriverActivityBO().DriverActivityUpdate(driverActivity);
                return(Ok(result ? UTILITY.LOGOUT : UTILITY.FAILEDMSG));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #12
0
 public IHttpActionResult DriverLoginIn(DriverLoginDTO driverLoginDTO)
 {
     try
     {
         var token = new DriverActivityBO().DriverLogIn(driverLoginDTO.driverID, driverLoginDTO.password, driverLoginDTO.latitude, driverLoginDTO.longitude);
         if (!string.IsNullOrWhiteSpace(token))
         {
             return(Ok(new
             {
                 token = token
             }));
         }
         else
         {
             return(Ok(new { Status = UTILITY.FAILEDMESSAGE }));
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
예제 #13
0
        public IHttpActionResult UpdateDriverDutyStatus(bool status, bool isintrip, string tripID)
        {
            try
            {
                var driverActivity = new DriverActivity
                {
                    DriverId  = HeaderValueByKey("DRIVERID"),
                    TokenNo   = HeaderValueByKey("AUTH_TOKEN"),
                    Latitude  = Convert.ToDecimal(HeaderValueByKey("LATITUDE")),
                    Longitude = Convert.ToDecimal(HeaderValueByKey("LONGITUDE")),
                    IsLogIn   = true,
                    IsOnDuty  = status
                };

                var driverActivityObj = new DriverActivity();
                if (isintrip)
                {
                    driverActivityObj = new DriverActivityBO().GetDriverActivity(new DriverActivity
                    {
                        TokenNo  = HeaderValueByKey("AUTH_TOKEN"),
                        DriverId = HeaderValueByKey("DRIVERID")
                    });

                    var frmLatLong = driverActivityObj.CurrentLat.ToString() + "," + driverActivityObj.CurrentLong.ToString();
                    var toLatLong  = driverActivity.Latitude + "," + driverActivity.Longitude;
                    var distance   = GetTravelTimeBetweenTwoLocations(frmLatLong, toLatLong).distance;

                    new TripBO().TripUpdateTravelledDistance(tripID, distance);
                }
                var result = new DriverActivityBO().DriverActivityUpdate(driverActivity);

                return(Ok(result ? UTILITY.SUCCESSMSG : UTILITY.FAILEDMSG));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #14
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var TYPE = HttpContext.Current.Request.Headers["TYPE"];

            if (string.IsNullOrWhiteSpace(TYPE))
            {
                var AUTH_TOKEN = HttpContext.Current.Request.Headers["AUTH_TOKEN"];
                var MOBILENO   = HttpContext.Current.Request.Headers["MOBILENO"];
                if (!string.IsNullOrWhiteSpace(AUTH_TOKEN) && !string.IsNullOrWhiteSpace(MOBILENO))
                {
                    var result = new CustomerLogInBO().AuthUser(
                        new CustomerLogin {
                        TokenNo = AUTH_TOKEN, MobileNo = MOBILENO
                    });

                    if (!result)
                    {
                        actionContext.Response = new HttpResponseMessage
                        {
                            Content    = new StringContent(UTILITY.INVALID),
                            StatusCode = HttpStatusCode.Unauthorized
                        };
                    }
                }
                else
                {
                    actionContext.Response = new HttpResponseMessage
                    {
                        Content    = new StringContent(UTILITY.FAILEDAUTH),
                        StatusCode = HttpStatusCode.Unauthorized
                    };
                }
            }
            else if (TYPE == "DRIVER")
            {
                var AUTH_TOKEN = HttpContext.Current.Request.Headers["AUTH_TOKEN"];
                var DRIVERID   = HttpContext.Current.Request.Headers["DRIVERID"];
                var LATITUDE   = HttpContext.Current.Request.Headers["LATITUDE"];
                var LONGITUDE  = HttpContext.Current.Request.Headers["LONGITUDE"];

                if (!string.IsNullOrWhiteSpace(AUTH_TOKEN) && !string.IsNullOrWhiteSpace(DRIVERID))
                {
                    var result = new DriverActivityBO().AuthenticateDriver(new DriverActivity {
                        TokenNo   = AUTH_TOKEN,
                        DriverID  = DRIVERID,
                        Latitude  = Convert.ToDecimal(LATITUDE),
                        Longitude = Convert.ToDecimal(LONGITUDE)
                    });

                    if (!result)
                    {
                        actionContext.Response = new HttpResponseMessage
                        {
                            Content    = new StringContent(UTILITY.INVALID),
                            StatusCode = HttpStatusCode.Unauthorized
                        };
                    }
                }
                else
                {
                    actionContext.Response = new HttpResponseMessage
                    {
                        Content    = new StringContent(UTILITY.FAILEDAUTH),
                        StatusCode = HttpStatusCode.Unauthorized
                    };
                }
            }
        }