コード例 #1
0
 public ActionResult ApproveTrip(int id)
 {
     using (context)
     {
         TripsTable trip = context.TripsTables.Where(x => x.TripID == id).FirstOrDefault();
         List <DriverDetailsTable> model = context.DriverDetailsTables.Where(x => x.VehicleType == trip.VehicleType).ToList();
         return(PartialView("ApprovePV", model));
     }
 }
コード例 #2
0
 public ActionResult ApproveTrip(ApproveTripModel model)
 {
     using (context)
     {
         TripsTable trip = context.TripsTables.Where(x => x.TripID == model.TripID).FirstOrDefault();
         trip.DriverID             = model.DriverID;
         trip.TripStatus           = (int)ETripStatus.APPROVED;
         context.Entry(trip).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("Approved"));
     }
 }
コード例 #3
0
        public ActionResult RejectTrip(int tripId)
        {
            using (context)
            {
                TripsTable trip = context.TripsTables.Where(x => x.TripID == tripId).FirstOrDefault();
                trip.TripStatus = (int)ETripStatus.REJECTED;

                context.Entry(trip).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();

                return(Json("success", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        public ActionResult ViewTrip(int id)
        {
            using (context)
            {
                TripViewModelAdmin model      = new TripViewModelAdmin();
                TripsTable         trip       = context.TripsTables.Where(x => x.TripID == id).FirstOrDefault();
                RiderDetailsTable  rider      = context.RiderDetailsTables.Where(x => x.RiderID == trip.UserID).FirstOrDefault();
                TripDetaisTable    tripDetail = context.TripDetaisTables.Where(x => x.TripID == trip.TripDetailsTableID).FirstOrDefault();
                if (trip.DriverID != null)
                {
                    DriverDetailsTable driver = context.DriverDetailsTables.Where(x => x.DriverID == trip.DriverID).FirstOrDefault();
                    model.Driver = driver;
                }
                model.Trips       = trip;
                model.Rider       = rider;
                model.TripDetails = tripDetail;

                return(PartialView("ViewTripPV", model));
            }
        }
コード例 #5
0
        public ActionResult SubmitTrip(ViewTripModel model)
        {
            try
            {
                if (Session["LoggedUserID"] == null)
                {
                    return(View("Login", model));
                }
                else if (Session["LoggedUserID"].ToString() == EUserType.ADMIN.ToString())
                {
                    TempData["ValidateMessage"] = "You Can't apply for the trip with an ADMIN account. Try with a RIDER account.";
                    return(View("Login", model));
                }
                else if (Session["LoggedUserID"].ToString() == EUserType.DRIVER.ToString())
                {
                    TempData["ValidateMessage"] = "You Can't apply for the trip with an DRIVER account. Try with a RIDER account.";
                    return(View("Login", model));
                }
                else
                {
                    TripsTable trip = new TripsTable();
                    trip.UserID             = Int32.Parse(Session["LoggedUserID"].ToString());
                    trip.TripDetailsTableID = model.tripId;
                    trip.TripStatus         = (int)ETripStatus.PENDING;
                    trip.PickupDate         = model.Date;
                    trip.VehicleType        = model.VehicleType;
                    trip.TripDays           = model.TripDays;
                    switch (model.VehicleType)
                    {
                    case 2:
                        trip.Amount = model.CarAmount.ToString();
                        break;

                    case 3:
                        trip.Amount = model.VanAmount.ToString();
                        break;

                    case 4:
                        trip.Amount = model.BusAmount.ToString();
                        break;

                    default:
                        trip.Amount = model.CarAmount.ToString();
                        break;
                    }

                    if (model.Time.Substring(model.Time.Length - 2) == "AM")
                    {
                        trip.PickupTime = TimeSpan.Parse(model.Time.Remove(model.Time.Length - 3));
                    }
                    else if (model.Time.Substring(model.Time.Length - 2) == "PM")
                    {
                        model.Time = model.Time.Remove(model.Time.Length - 3);
                        int hr = Int32.Parse(model.Time.Remove(model.Time.IndexOf(":"))) + 12;
                        if (hr == 24)
                        {
                            hr = 12;
                        }
                        string min = model.Time.Substring(model.Time.IndexOf(":") + 1);
                        trip.PickupTime = TimeSpan.Parse(hr.ToString() + ":" + min);
                    }

                    context.TripsTables.Add(trip);
                    context.SaveChanges();

                    return(View());
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index"));
            }
        }