public ActionResult Index(Site_Users user) { //Return the number of rows returned from the database (should be 1) int count = db.Site_Users.Where( u => u.Email == user.Email && u.Passward == user.Passward).Count(); if (count == 1) { //set the authcookie with your username or any other value. This username is also being used to determine your user role. FormsAuthentication.SetAuthCookie(user.Email, false); Site_Users u = db.Site_Users.SingleOrDefault(su => su.Email == user.Email); if (user.Email == "*****@*****.**") { return(RedirectToAction("AdminHomePage", new { id = u.Id })); } else { return(RedirectToAction("UserHomePage", new { id = u.Id })); } } ViewBag.Message = "Invalid username and/or password"; return(View(user)); }
public ActionResult DeleteConfirmed(int id) { Site_Users site_Users = db.Site_Users.Find(id); db.Site_Users.Remove(site_Users); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,First_Name,Last_Name,Email,Passward,User_Role_Code,New_Msg_Id")] Site_Users site_Users) { if (ModelState.IsValid) { db.Entry(site_Users).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.User_Role_Code = new SelectList(db.Site_Roles, "Role_Code", "Role_Name", site_Users.User_Role_Code); return(View(site_Users)); }
// GET: Site_Users/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Site_Users site_Users = db.Site_Users.Find(id); if (site_Users == null) { return(HttpNotFound()); } return(View(site_Users)); }
// GET: Site_Users/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Site_Users site_Users = db.Site_Users.Find(id); if (site_Users == null) { return(HttpNotFound()); } ViewBag.User_Role_Code = new SelectList(db.Site_Roles, "Role_Code", "Role_Name", site_Users.User_Role_Code); return(View(site_Users)); }
public PartialViewResult Users_DDL(FormCollection form) { //Set up country instance Site_Users user = new Site_Users(); //store the result from the form with Name="Country" //string user_id = form["user"]; try { int user_id = Convert.ToInt32(form["user"]); user = db.Site_Users.SingleOrDefault(c => c.Id == user_id); } catch (Exception genericException) { //Catch possible errors from interacting with the database ViewBag.ExceptionMessage = genericException.Message; return(PartialView("~/Views/Errors/_Partial_Error.cshtml")); } //Render the PartialView with the country object. return(PartialView("~/Views/Site_Users/_User.cshtml", user)); }