public ActionResult Edit(RouteMileage model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                try
                {
                    CarraraSQL.RouteMileages.Attach(model);
                    CarraraSQL.RouteMileages.Remove(model);
                    CarraraSQL.SaveChanges();
                    TempData["Page.Title"] = "The Route Mileage Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Route Mileage Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Route Mileage Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Route Mileage Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
        public ActionResult Edit(int guid)
        {
            RouteMileage         model      = CarraraSQL.RouteMileages.Find(guid);
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model == null)
            {
                TempData["Page.Title"] = "Unable to Locate Route Mileage with Id " + guid.ToString() + "!";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title = TempData["Page.Title"] != null ? TempData["Page.Title"].ToString() : "Edit Mileage for " + model.State.StateAbbreviation + "-" + model.Route.RouteName;
            return(View("Manage", model));
        }
        public ActionResult Add(RouteMileage model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (ModelState.IsValid)
            {
                CarraraSQL.RouteMileages.Add(model);
                CarraraSQL.SaveChanges();
                TempData["Page.Title"] = "The Route Mileage Was Added Successfully!";
                return(RedirectToAction("Index", parameters));
            }
            // Failure is always an option...
            Page.Title   = "The Route Mileage Was NOT Added!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }