public ActionResult UserList() { if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (Session["uType"] == null) { return(RedirectToAction("Index", "Home")); } DemoEntities db = new DemoEntities(); //IEnumerable<MaidEasy.Models.user> us = db.users.ToList(); IEnumerable <MaidEasy.Models.user> userList = dbContext.users.ToList(); RegisterController regC = new RegisterController(); foreach (var item in userList) { int id = regC.getThanaID(item.thana); thana thana = dbContext.thana.Find(id); item.thana = thana.Name; System.Diagnostics.Debug.WriteLine("--------------"); System.Diagnostics.Debug.WriteLine(thana.ThanaId); System.Diagnostics.Debug.WriteLine(thana.Name); System.Diagnostics.Debug.WriteLine("--------------"); } return(View(userList)); }
public ActionResult DeleteConfirm(int id) { if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (Session["uType"] == null) { return(RedirectToAction("Index", "Home")); } thana thana = Db.thana.Find(id); Db.thana.Remove(thana); Db.SaveChanges(); Session["ADMIN_THANA_DELETE"] = "Admin Thana Delete"; return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "")] thana thana) { if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (Session["uType"] == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { Db.Entry(thana).State = EntityState.Modified; Db.SaveChanges(); } return(RedirectToAction("Index")); }
// GET: AdminThana/Edit/5 public ActionResult Edit(int id) { if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (Session["uType"] == null) { return(RedirectToAction("Index", "Home")); } thana thana = Db.thana.Find(id); if (thana == null) { return(HttpNotFound()); } return(View(thana)); }
public ActionResult Create([Bind(Include = "")] thana thana) { if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (Session["uType"] == null) { return(RedirectToAction("Index", "Home")); } // TODO: Add insert logic here if (ModelState.IsValid) { Db.thana.Add(thana); Db.SaveChanges(); } return(RedirectToAction("Index")); }
private string getThana(string s) { int id = 0, len = s.Length; for (int i = 0; i < len; i++) { if (s[i] == '1') { id = i + 1; break; } } thana thana = dbContext.thana.Find(id); return(thana.Name); /*DBHelper db = DBHelper.getDB(); * string sql = "SELECT Name from Thana where ThanaId = '" + id + "'"; * var table = db.getData(sql); * table.Read(); * string ret = table.GetString(0); * table.Close(); * return ret;*/ }