public ActionResult Create(SuplierTable suplierTable) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"]))) { return(RedirectToAction("Login", "Home")); } int userid = Convert.ToInt32(Convert.ToString(Session["UserID"])); suplierTable.UserID = userid; if (ModelState.IsValid) { var find = db.SuplierTables.Where(s => s.SuplierName == suplierTable.SuplierName && s.ContactNo == suplierTable.ContactNo).FirstOrDefault(); if (find == null) { db.SuplierTables.Add(suplierTable); db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.Massege = "Suplier Alredy Registerd"; } } return(View(suplierTable)); }
// GET: SuplierTables/Details/5 public ActionResult Details(int?id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"]))) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuplierTable suplierTable = db.SuplierTables.Find(id); if (suplierTable == null) { return(HttpNotFound()); } return(View(suplierTable)); }
public ActionResult Edit(SuplierTable suplierTable) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"]))) { return(RedirectToAction("Login", "Home")); } int userid = Convert.ToInt32(Convert.ToString(Session["UserID"])); suplierTable.UserID = userid; if (ModelState.IsValid) { db.Entry(suplierTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.UserTables, "UserID", "UserName", suplierTable.UserID); return(View(suplierTable)); }
// GET: SuplierTables/Edit/5 public ActionResult Edit(int?id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"]))) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SuplierTable suplierTable = db.SuplierTables.Find(id); if (suplierTable == null) { return(HttpNotFound()); } ViewBag.UserID = new SelectList(db.UserTables, "UserID", "UserName", suplierTable.UserID); return(View(suplierTable)); }