public ActionResult Account_deital() { userr users = (userr)Session["UserAccount"]; userr use = data.userrs.SingleOrDefault(n => n.id == users.id); return(View(use)); }
public ActionResult login(userr us) { userr a = context.userrs.Where(u => u.userr_name == us.userr_name && u.userr_password == us.userr_password).FirstOrDefault(); admin a2 = context.admins.Where(u2 => u2.ad_username == us.userr_name && u2.ad_password == us.userr_password).FirstOrDefault(); if (a != null) { Session["u_name"] = a.userr_name.ToString(); Session["u_id"] = a.userr_id.ToString(); return(RedirectToAction("Index")); } else if (a2 != null) { Session["name"] = a2.ad_username.ToString(); Session["ad_id"] = a2.ad_id.ToString(); return(RedirectToAction("ViewCategory", "admin")); } else { ViewBag.error = "invalid username or password"; return(View()); } //return View(); }
public ActionResult Remove_favorite(int id) { userr users = (userr)Session["UserAccount"]; var fav = from f in data.favorites where f.film_id == id && f.user_id == users.id select f; if (users != null) { if (fav.Count() > 0) { data.favorites.DeleteOnSubmit(fav.Single()); data.SubmitChanges(); return(RedirectToAction("Film_single", "Home", new { id = id })); } else { return(HttpNotFound()); } } else { return(HttpNotFound()); } }
public ActionResult Register(userr use, FormCollection collection) { string email = collection["email"]; string password = collection["password"]; string repassword = collection["repassword"]; use.created = DateTime.Now; //kiem tra ton tai tai khoan trung email userr Use_email = data.userrs.SingleOrDefault(n => n.email == email); if (CheckPassword(password) == false) { ViewBag.Notification = "Password must include a capital letter, a lowercase letter, a character, a number, minimum 8 characters, maximum 16 characters and do not include spaces."; return(View(use)); } else { // kiem tra mat khau trung nhau if (password != repassword) { { ViewBag.Notification = "The password is not the same"; return(View(use)); } } else { //kiem tra ton tai tai khoan trung email if (Use_email != null) { ViewBag.Notification = "Email already exists !!!"; } else { // kiem tra du lieu nhap vao != rong if (ModelState.IsValid) { data.userrs.InsertOnSubmit(use); data.SubmitChanges(); return(RedirectToAction("Register_Success", "User")); } else { ; } } } } return(View(use)); }
public ActionResult Account_edit(userr use, FormCollection collection) { userr user = data.userrs.First(n => n.email == use.email); if (ModelState.IsValid) { user.first_name = collection["first_name"]; user.last_name = collection["last_name"]; UpdateModel(use); data.SubmitChanges(); ViewBag.Notification = "Updated your information"; return(RedirectToAction("Account_deital")); } return(View(use)); }
// partial view tai khoan hien thi tren trang chu sau khi dang nhap thanh cong public PartialViewResult Account() { userr users = (userr)Session["UserAccount"]; if (Session["UserAccount"] != null) { userr use = data.userrs.SingleOrDefault(n => n.id == users.id); ViewBag.User_name = use.first_name; } else { ViewBag.User_name = null; } return(PartialView()); }
public ActionResult Add_review(FormCollection collection) { if (ModelState.IsValid) { review revie = new review(); if (Session["UserAccount"] == null) { return(new HttpNotFoundResult()); // 404 } else { userr users = (userr)Session["UserAccount"]; int film_id = int.Parse(collection["film"]); revie.created = DateTime.Now; revie.user_id = users.id; revie.film_id = film_id; revie.comment = collection["comment"]; revie.title = collection["title"]; revie.point = int.Parse(collection["point"]); data.reviews.InsertOnSubmit(revie); data.SubmitChanges(); // cap nhat diem cua phim var review = data.reviews.Where(or => or.film_id == film_id).ToList(); if (review.Count() > 0) { int sum = 0; foreach (var item in review) { sum += int.Parse((item.point).ToString()); } float point = sum / (review.Count()); film fil = data.films.Where(or => or.id == film_id).FirstOrDefault(); fil.rate = int.Parse((Math.Ceiling(point)).ToString()); UpdateModel(fil); data.SubmitChanges(); } else { ; } return(RedirectToAction("Film_single", "Home", new { id = film_id })); } } else { return(HttpNotFound()); } }
public ActionResult Add_favorite(int id) { if (Session["UserAccount"] != null) { userr users = (userr)Session["UserAccount"]; favorite fav = new favorite(); fav.user_id = users.id; fav.film_id = id; fav.created = DateTime.Now; data.favorites.InsertOnSubmit(fav); data.SubmitChanges(); return(RedirectToAction("Film_single", "Home", new { id = id })); } else { return(HttpNotFound()); } }
public ActionResult Write_review(int id, int rate) { userr users = (userr)Session["UserAccount"]; if (Session["UserAccount"] != null) { ViewBag.film_id = id; ViewBag.rate = rate; userr use = data.userrs.SingleOrDefault(n => n.id == users.id); ViewBag.first_name = use.first_name; ViewBag.last_name = use.last_name; ViewBag.email = use.email; } else { return(RedirectToAction("Login_to", "User", new { film_id = id })); } return(View(data.films.Where(or => or.id == id).FirstOrDefault())); }
public ActionResult Login(FormCollection collection) { var email = collection["email"]; var password = collection["password"]; userr use = data.userrs.SingleOrDefault(n => n.email == email && n.password == password); // kiem tra ton tai tai khoan if (use == null) { ViewBag.Notification = "Email or password is incorrect !!!"; } else { // set session account Session["UserAccount"] = use; return(RedirectToAction("Index", "Home")); } return(View()); }
// Binh luan noi bat - neu chua dang nhap hoac da dang nhap nhung chua danh gia phim nay thi lay binh luan moi nhat, //neu da danh gia thi lay binh luan cua tai khoan dang dang nhap public ActionResult Film_review(int id) { if (Session["UserAccount"] != null) { userr users = (userr)Session["UserAccount"]; var review = from re in data.reviews where re.user_id == users.id && re.film_id == id select re; if (review.Count() > 0) { ViewBag.check = true; return(PartialView(review.Single())); } else { var rev = data.reviews.Where(or => or.film_id == id).OrderByDescending(a => a.id).FirstOrDefault(); if (rev != null) { return(PartialView(rev)); } else { ViewBag.check = false; return(PartialView()); } } } else { var rev = data.reviews.Where(or => or.film_id == id).OrderByDescending(a => a.id).FirstOrDefault(); if (rev != null) { return(PartialView(rev)); } else { ViewBag.check = false; return(PartialView()); } } }
public ActionResult Login_to(FormCollection collection) { var email = collection["email"]; var password = collection["password"]; int film_id = int.Parse(collection["film_id"]); userr use = data.userrs.SingleOrDefault(n => n.email == email && n.password == password); // kiem tra ton tai tai khoan if (use == null) { ViewBag.Notification = "Email or password is incorrect !!!"; ViewBag.Notification_2 = null; return(RedirectToAction("Login_to", "User", new { film_id = film_id })); } else { // set session account Session["UserAccount"] = use; return(RedirectToAction("Film_single", "Home", new { id = film_id })); } }
private void button1_Click(object sender, EventArgs e) { userr u = new userr() { name = textBox1.Text, email = textBox2.Text, mobileno = textBox3.Text, password = textBox4.Text, }; if (service.adduser(u)) { this.Hide(); Form2 f2 = new Form2(); f2.Show(); } else { label7.ForeColor = Color.Red; label7.Text = "Error while Register"; } }
public ActionResult Partial_favorite(int id) { userr users = (userr)Session["UserAccount"]; if (users == null) { return(PartialView(-1)); } else { var fav = from f in data.favorites where f.film_id == id && f.user_id == users.id select f; if (fav.Count() > 0) { ViewBag.check = 1; return(PartialView(id)); } ViewBag.check = 0; return(PartialView(id)); } }
// Kiem tra danh gia public ActionResult Check_rate(int id) { ViewBag.id = id; if (Session["UserAccount"] != null) { userr users = (userr)Session["UserAccount"]; var review = from re in data.reviews where re.film_id == id && re.user_id == users.id select re; if (review.Count() != 0) { return(PartialView(review.Single())); } else { return(PartialView()); } } else { return(PartialView()); } }
public ActionResult Create_user(userr user, FormCollection collection) { if (ModelState.IsValid) { string password = collection["password"]; if (!CheckPassword(password)) { ViewBag.Notification = "Password incorrect format"; return(View(user)); } else { user.created = DateTime.Now; data.userrs.InsertOnSubmit(user); data.SubmitChanges(); } } else { return(HttpNotFound()); } return(RedirectToAction("List_users")); }
public ActionResult SignUp(userr us, HttpPostedFileBase file) { if (context.userrs.Any(c => c.userr_name.Equals(us.userr_name))) { ModelState.AddModelError("", "Name Already Found"); return(View(us)); } if (ModelState.IsValid == false) { return(View(us)); } string path = uploadimgfile(file); if (path.Equals("-1")) { ViewBag.error = "Image could not be uploaded......"; } else { userr user1 = new userr(); user1.userr_name = us.userr_name; user1.userr_email = us.userr_email; user1.userr_password = us.userr_password; user1.userr_phone = us.userr_phone; user1.userr_image = path; user1.type = "user"; context.userrs.Add(user1); context.SaveChanges(); return(RedirectToAction("login")); } return(View()); }