public ActionResult Create(t_volunteer t_volunteer) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { var create = db.t_volunteer.Create(); create.vol_card_id = t_volunteer.vol_card_id; create.vol_name = t_volunteer.vol_name; create.vol_phone = t_volunteer.vol_phone; create.vol_address = t_volunteer.vol_address; create.vol_occupation = t_volunteer.vol_occupation; create.vol_email = t_volunteer.vol_email; create.kegiatan_id = t_volunteer.kegiatan_id; db.t_volunteer.Add(create); db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.kegiatan = new SelectList((from table in db.t_kegiatan select table).ToList(), "kegiatan_id", "kegiatan_nama"); return(View(t_volunteer)); } }
public ActionResult Edit(int id, t_volunteer volunteer) { if (ModelState.IsValid) { using (var db = new db_esosEntities()) { t_volunteer t_volunteer = db.t_volunteer.Find(id); t_volunteer.vol_card_id = volunteer.vol_card_id; t_volunteer.vol_name = volunteer.vol_name; t_volunteer.vol_phone = volunteer.vol_phone; t_volunteer.vol_address = volunteer.vol_address; t_volunteer.vol_occupation = volunteer.vol_occupation; t_volunteer.vol_email = volunteer.vol_email; t_volunteer.kegiatan_id = volunteer.kegiatan_id; db.SaveChanges(); return(RedirectToAction("Index")); } } else { ViewBag.kegiatan = new SelectList((from table in db.t_kegiatan select table).ToList(), "kegiatan_id", "kegiatan_nama"); return(View(volunteer)); } }
public ActionResult DeleteConfirmed(long id) { t_volunteer t_volunteer = db.t_volunteer.Find(id); db.t_volunteer.Remove(t_volunteer); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(long id = 0) { t_volunteer t_volunteer = db.t_volunteer.Find(id); ViewBag.kegiatan = new SelectList((from table in db.t_kegiatan select table).ToList(), "kegiatan_id", "kegiatan_nama"); if (t_volunteer == null) { return(HttpNotFound()); } return(View(t_volunteer)); }
public ActionResult Details(long id = 0) { t_volunteer t_volunteer = db.t_volunteer.Find(id); var idKeg = (from table in db.t_volunteer where table.vol_id == id select table.kegiatan_id).FirstOrDefault(); ViewBag.kegiatan = (from table in db.t_kegiatan where table.kegiatan_id == idKeg select table.kegiatan_nama).FirstOrDefault(); if (t_volunteer == null) { return(HttpNotFound()); } return(View(t_volunteer)); }