// GET: StudentHour/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentHour studentHour = db.StudentHours.Find(id); if (studentHour == null) { return(HttpNotFound()); } var userId = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(User.Identity); ViewBag.Communities = db.Communities .Where(c => c.PrimaryUserId == userId) .Select(c => new SelectListItem { Text = c.CommunityName, Value = c.Id.ToString() }) .ToList <SelectListItem>(); return(View(studentHour)); }
public ActionResult DeleteConfirmed(int id) { StudentHour studentHour = db.StudentHours.Find(id); db.StudentHours.Remove(studentHour); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: StudentHour/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StudentHour studentHour = db.StudentHours.Find(id); if (studentHour == null) { return(HttpNotFound()); } return(View(studentHour)); }
public ActionResult Edit([Bind(Include = "Id,StudentId,ServiceDate,CommunityHours,ServiceThreshhold")] StudentHour studentHour) { if (ModelState.IsValid) { db.Entry(studentHour).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } var userId = Microsoft.AspNet.Identity.IdentityExtensions.GetUserId(User.Identity); ViewBag.Communities = db.Communities .Where(c => c.PrimaryUserId == userId) .Select(c => new SelectListItem { Text = c.CommunityName, Value = c.Id.ToString() }) .ToList <SelectListItem>(); return(View(studentHour)); }