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")); }
public Location(SuccesfulRideForm s) { Latitude = s.Latitude; Longitude = s.Longitude; Street = s.Street; StreetNumber = s.StreetNumber; City = s.City; PostalCode = s.PostalCode; }
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)); }
public void Update(SuccesfulRideForm f) { Destination = new Location(f); Price = f.Price; Status = RideStatus.Successful; }