Example #1
0
        public ActionResult Edit(LocationEditForm form)
        {
            var user = (ApplicationUser)Session["User"];

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

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

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

            var appUser = db.ApplicationUsers.SingleOrDefault(u => u.Id == user.Id);

            if (appUser == null)
            {
                return(HttpNotFound());
            }

            var loc = new Location(form);

            appUser.EditLocation(loc);
            Session["User"] = appUser;
            db.SaveChanges();

            return(RedirectToAction("Home", "Home"));
        }
Example #2
0
        public ActionResult Edit()
        {
            var user = (ApplicationUser)Session["User"];

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

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

            var appUser = db.ApplicationUsers.Include(u => u.Location).SingleOrDefault(u => u.Id == user.Id);

            if (appUser == null)
            {
                return(HttpNotFound());
            }

            var locEditForm = new LocationEditForm(appUser.Location);

            return(View(locEditForm));
        }
Example #3
0
 public Location(LocationEditForm f)
 {
     Latitude     = f.Latitude;
     Longitude    = f.Longitude;
     Street       = f.Street;
     StreetNumber = f.StreetNumber;
     City         = f.City;
     PostalCode   = f.PostalCode;
 }