Exemplo n.º 1
0
        public ActionResult AddDriver(DriverDetailsTable model)
        {
            using (context)
            {
                model.IsDeleted      = (int)EIsDeleted.NO;
                model.IsOnline       = (int)EAvailability.OFFLINE;
                model.RegisteredDate = DateTime.Now;
                model.Status         = (int)EUserStatus.PENDING;

                HttpPostedFileBase file = Request.Files[0];
                if (file.ContentLength > 0)
                {
                    string fileName = model.FirstName + DateTime.Now.ToString("yyMMddhhmmss") + Path.GetExtension(file.FileName);

                    model.UserImageUrl = "~/Images/Drivers/" + fileName;

                    fileName = Path.Combine(
                        Server.MapPath("~/Images/Drivers/"), fileName);
                    file.SaveAs(fileName);
                }

                context.DriverDetailsTables.Add(model);
                context.SaveChanges();

                TempData["Success"] = "Added Successfully!";

                return(RedirectToAction("Active"));
            }
        }
Exemplo n.º 2
0
        public ActionResult RegisterDriver(DriverDetailsTable model)
        {
            try
            {
                HttpPostedFileBase file = Request.Files[0];
                if (file.ContentLength > 0)
                {
                    string fileName = model.FirstName + DateTime.Now.ToString("yyMMddhhmmss") + Path.GetExtension(file.FileName);
                    model.UserImageUrl = "~/Images/Drivers/" + fileName;
                    fileName           = Path.Combine(
                        Server.MapPath("~/Images/Drivers/"), fileName);
                    file.SaveAs(fileName);
                }
                model.Password        = BCrypt.Net.BCrypt.HashString(model.Password);
                model.CurrentLocation = "Maradana, Colombo, Sri Lanka";
                model.RegisteredDate  = DateTime.Now;
                model.Status          = 1;

                context.DriverDetailsTables.Add(model);
                context.SaveChanges();

                return(RedirectToAction("Login", "UserHome", new { area = "" }));
            }
            catch (Exception e)
            {
                string msg = e.ToString();
                return(RedirectToAction("RegisterDriver", "Login", new { area = "DriverHome" }));
            }
        }
Exemplo n.º 3
0
 public ActionResult EditDriver(int driverId)
 {
     using (context)
     {
         DriverDetailsTable rdr = context.DriverDetailsTables.Where(x => x.DriverID == driverId).FirstOrDefault();
         return(PartialView("EditDriverPV", rdr));
     }
 }
Exemplo n.º 4
0
 public ActionResult EditDriver(DriverDetailsTable driver)
 {
     using (context)
     {
         context.Entry(driver).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("Active", "Driver", new { area = "Admin" }));
     }
 }
Exemplo n.º 5
0
        public ActionResult RestoreDriver(int driverId)
        {
            using (context)
            {
                DriverDetailsTable dr = context.DriverDetailsTables.Where(x => x.DriverID == driverId).FirstOrDefault();
                dr.Status = (int)EUserStatus.PENDING;

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

                return(Json("success", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 6
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));
            }
        }
        public JsonResult Authorize(ViewTripModel model)
        {
            using (context)
            {
                UserLoginDetail obj = context.UserLoginDetails.Where(x => x.UserLoginEmail == model.UserName || x.UserLoginMobile.ToString() == model.UserName).FirstOrDefault();
                if (obj == null)
                {
                    TempData["ValidateMessage"] = "The username is doesnt exist in the context";
                    return(Json(Response, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (model.Password.Contains("$"))
                    {
                        if (BCrypt.Net.BCrypt.Verify(model.Password, obj.UserLoginPassword))
                        {
                            if (obj.UserType == 2)
                            {
                                Session["LoggedUserID"] = obj.UserTableID;
                                DriverDetailsTable dr = context.DriverDetailsTables.Where(x => x.DriverID == obj.UserTableID).FirstOrDefault();
                                Session["LoggedUserName"] = dr.FirstName;
                                Session["ImageUrl"]       = dr.UserImageUrl;

                                // return RedirectToAction("Home", "DriverDash", new { area = "DriverHome" });
                            }
                            else if (obj.UserType == 3)
                            {
                                Session["LoggedUserID"] = obj.UserTableID;
                                RiderDetailsTable rd = context.RiderDetailsTables.Where(x => x.RiderID == obj.UserTableID).FirstOrDefault();
                                Session["LoggedUserName"] = rd.FirstName;
                                // return RedirectToAction("Index", "UserHome", new { area = "" });
                            }
                            else if (obj.UserType == 1)
                            {
                                Session["LoggedUserID"] = obj.UserTableID;
                                AdminDetailsTable ad = context.AdminDetailsTables.Where(x => x.AdminID == obj.UserTableID).FirstOrDefault();
                                Session["LoggedUserName"] = ad.FirstName;
                                Session["ImageUrl"]       = ad.UserImageUrl;
                                // return RedirectToAction("Index", "Home", new { area = "Admin" });
                            }
                        }
                    }
                    else if (obj.UserLoginPassword == model.Password)
                    {
                        if (obj.UserType == 2)
                        {
                            Session["LoggedUserID"] = obj.UserTableID;
                            DriverDetailsTable dr = context.DriverDetailsTables.Where(x => x.DriverID == obj.UserTableID).FirstOrDefault();
                            Session["LoggedUserName"] = dr.FirstName;
                            Session["ImageUrl"]       = dr.UserImageUrl;

                            //return RedirectToAction("Home", "DriverDash", new { area = "DriverHome" });
                        }
                        else if (obj.UserType == 3)
                        {
                            Session["LoggedUserID"] = obj.UserTableID;
                            RiderDetailsTable rd = context.RiderDetailsTables.Where(x => x.RiderID == obj.UserTableID).FirstOrDefault();
                            Session["LoggedUserName"] = rd.FirstName;
                            // return RedirectToAction("Index", "UserHome", new { area = "" });
                        }
                        else if (obj.UserType == 1)
                        {
                            Session["LoggedUserID"] = obj.UserTableID;
                            AdminDetailsTable ad = context.AdminDetailsTables.Where(x => x.AdminID == obj.UserTableID).FirstOrDefault();
                            Session["LoggedUserName"] = ad.FirstName;
                            Session["ImageUrl"]       = ad.UserImageUrl;
                            //return RedirectToAction("Index", "Home", new { area = "Admin" });
                        }
                    }
                    else
                    {
                        TempData["ValidateMessage"] = "The password is incorrect";
                        ViewBag.Message             = "The password is incorrect";
                        //return RedirectToAction("Login", "UserHome", model);
                    }
                }
            }
            return(Json(Response));
        }