public ActionResult DeleteConfirmed(int id) { GolfHole golfHole = db.GolfHoles.Find(id); db.GolfHoles.Remove(golfHole); db.SaveChanges(); return(RedirectToAction("Index")); }
public EventGolfModel(EventGolf golf) { EventGolf = golf; EventBookedProducts = new ObservableCollection <EventBookedProductModel>(); _golfHole = EventGolf.GolfHole; _golf = EventGolf.Golf; }
public GolfHole UpdateHole(GolfHole updatedHole) { GolfHole hole = holes.SingleOrDefault(h => h.HoleNum == updatedHole.HoleNum); if (hole != null) { hole.PlayerScore = updatedHole.PlayerScore; } return(hole); }
public ActionResult Edit([Bind(Include = "GolfCourseID,HoleNum,Par,Handicap")] GolfHole golfHole) { if (ModelState.IsValid) { db.Entry(golfHole).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GolfCourseID = new SelectList(db.Courses, "GolfCourseID", "Name", golfHole.GolfCourseID); return(View(golfHole)); }
// GET: GolfHoles/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GolfHole golfHole = db.GolfHoles.Find(id); if (golfHole == null) { return(HttpNotFound()); } return(View(golfHole)); }
// GET: GolfHoles/Edit/5 public ActionResult Edit(int?CourseID, int?HoleNum) { if (CourseID == null || HoleNum == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GolfHole golfHole = db.GolfHoles.Find(CourseID, HoleNum); if (golfHole == null) { return(HttpNotFound()); } return(View(golfHole)); }
public ActionResult Create([Bind(Include = "GolfCourseID,Name,CourseSlope,CourseRating")] GolfCourse golfCourse) { if (ModelState.IsValid) { //need to put a try catch here to maker sure the db action succeeds - primary keys may be invalid db.Courses.Add(golfCourse); db.SaveChanges(); for (var i = 0; i < 18; i++) { var h = new GolfHole(); h.HoleNum = i + 1; h.Par = 4; h.GolfCourseID = golfCourse.GolfCourseID; db.GolfHoles.Add(h); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(golfCourse)); }