public ActionResult Create(usta usta, hesap hesap) { //usta.hesapID = hesap.ID; //if (ModelState.IsValid) bunu yapınca olmadı //{ if (User.IsInRole("T2")) { var hesapdb2 = db.hesap.Where(i => i.ID == hesap.ID).FirstOrDefault(); var taserondb = db.taseron.Where(i => i.hesap.mail == User.Identity.Name).FirstOrDefault(); usta.taseronID = taserondb.ID; usta.hesapID = hesapdb2.ID; hesapdb2.rol = "U2"; db.usta.Add(usta); db.SaveChanges(); return(RedirectToAction("Index")); } var hesapdb = db.hesap.Where(i => i.mail == User.Identity.Name).FirstOrDefault(); var id = hesapdb.ID; usta.hesapID = id; db.usta.Add(usta); hesapdb.rol = "U2"; db.SaveChanges(); return(RedirectToAction("Index")); //} ViewBag.hesapID = new SelectList(db.hesap, "ID", "mail", usta.hesapID); ViewBag.taseronID = new SelectList(db.taseron, "ID", "ad", usta.taseronID); return(View(usta)); }
public ActionResult DeleteConfirmed(int id) { usta usta = db.usta.Find(id); db.usta.Remove(usta); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult TUSilOnay(int id) { usta usta = db.usta.Find(id); if (usta == null) { return(HttpNotFound()); } usta.taseronID = 1; db.SaveChanges(); return(RedirectToAction("Index", "usta")); }
public ActionResult Edit([Bind(Include = "ID,hesapID,ad,soyad,taseronID")] usta usta) { if (ModelState.IsValid) { db.Entry(usta).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.hesapID = new SelectList(db.hesap, "ID", "mail", usta.hesapID); ViewBag.taseronID = new SelectList(db.taseron, "ID", "ad", usta.taseronID); return(View(usta)); }
// GET: usta/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } usta usta = db.usta.Find(id); if (usta == null) { return(HttpNotFound()); } return(View(usta)); }
public ActionResult Edit(int?id) { if (User.IsInRole("U2")) { var ustadb = db.usta.Where(i => i.hesap.mail == User.Identity.Name).FirstOrDefault(); var userid = ustadb.ID; if (id == null || id == userid) { return(View(ustadb)); } } if (User.IsInRole("A") || User.IsInRole("T2")) { if (User.IsInRole("T2")) { var taserondb = db.taseron.Where(x => x.hesap.mail == User.Identity.Name).FirstOrDefault(); var tasid = taserondb.ID; usta ustadb = db.usta.Find(id); if (ustadb.taseronID == tasid) { return(View(ustadb)); } else { return(RedirectToAction("Index", "Home")); } } usta usta = db.usta.Find(id); ViewBag.hesapID = new SelectList(db.hesap, "ID", "mail", usta.hesapID); ViewBag.taseronID = new SelectList(db.taseron, "ID", "ad", usta.taseronID); return(View(usta)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult TUSil(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } usta usta = db.usta.Find(id); if (usta == null) { return(HttpNotFound()); } var taserondb = db.taseron.Where(x => x.hesap.mail == User.Identity.Name).FirstOrDefault(); var tasid = taserondb.ID; if (usta.taseronID == tasid) { return(View(usta)); } else { return(RedirectToAction("Index", "Home")); } }