コード例 #1
0
        public ActionResult Successful(SuccesfulRideForm form)
        {
            var user = (ApplicationUser)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("SignIn", "Login"));
            }

            if (user.Role != UserRole.Driver)
            {
                return(new HttpUnauthorizedResult());
            }

            if (!ModelState.IsValid)
            {
                return(View("Successful", form));
            }

            var ride   = db.Rides.Include(r => r.Driver).SingleOrDefault(r => r.Id == form.IdR);
            var driver = db.ApplicationUsers.SingleOrDefault(u => u.Id == ride.Driver.Id);
            var loc    = new Location(form);

            ride.Update(form);
            driver.IsDriverBusy = false;
            Session["User"]     = driver;
            db.SaveChanges();

            return(RedirectToAction("Home", "Home"));
        }
コード例 #2
0
ファイル: Location.cs プロジェクト: BZug/taxi2018
 public Location(SuccesfulRideForm s)
 {
     Latitude     = s.Latitude;
     Longitude    = s.Longitude;
     Street       = s.Street;
     StreetNumber = s.StreetNumber;
     City         = s.City;
     PostalCode   = s.PostalCode;
 }
コード例 #3
0
        public ActionResult Successful(int id)
        {
            var user = (ApplicationUser)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("SignIn", "Login"));
            }

            if (user.Role != UserRole.Driver)
            {
                return(new HttpUnauthorizedResult());
            }

            var successfulF = new SuccesfulRideForm(id);

            return(View(successfulF));
        }
コード例 #4
0
 public void Update(SuccesfulRideForm f)
 {
     Destination = new Location(f);
     Price       = f.Price;
     Status      = RideStatus.Successful;
 }