public ActionResult Index(Register_table r) { if (ModelState.IsValid) { var usr = (from u in msample1.Register_table where u.username == r.username select u).FirstOrDefault(); if (usr == null) { msample1.Register_table.Add(new Register_table { name = r.name, email = r.email, phone = r.phone, username = r.username, password = r.password, confirmpassword = r.confirmpassword, address = r.address, datex = DateTime.Now.ToString() }); msample1.SaveChanges(); return(RedirectToAction("Index")); } else { TempData["AE"] = "This user name is already exist"; return(RedirectToAction("Admin")); } } return(View(r)); }
public ActionResult Details(int Id) { if (Session["username"] == null || Session["userid"].ToString() == null) { TempData["Message"] = "You Have To Login !!!!"; return(this.RedirectToAction("Login", "Home")); } Register_table rt = msample1.Register_table.Find(Id); if (rt == null) { return(HttpNotFound()); } return(View(rt)); }
public ActionResult Edit(Register_table r) { if (Session["username"] == null || Session["userid"].ToString() == null) { TempData["Message"] = "You Have To Login !!!!"; return(this.RedirectToAction("Login", "Home")); } if (ModelState.IsValid) { Register_table existing = msample1.Register_table.Find(r.id); existing.name = r.name; existing.email = r.email; existing.phone = r.phone; existing.password = r.password; existing.confirmpassword = r.confirmpassword; existing.address = r.address; if (existing.username != r.username) { var userCount = (from u in msample1.Register_table where u.username == r.username select u).Count(); if (userCount == 0) { existing.username = r.username; } else { TempData["AE"] = "This user name is already exist"; return(RedirectToAction("Admin")); } } if (existing.datex == null) { existing.datex = DateTime.Now.ToString(); } else { existing.datex = existing.datex; } msample1.SaveChanges(); return(RedirectToAction("Homepage", "Home")); } return(RedirectToAction("Homepage", "Home")); }
public ActionResult Edit(int?Id) { if (Session["username"] == null || Session["userid"].ToString() == null) { TempData["Message"] = "You Have To Login !!!!"; return(this.RedirectToAction("Login", "Home")); } //if (Id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} Register_table rt = msample1.Register_table.Find(Id); if (rt == null) { return(HttpNotFound()); } return(View(rt)); }