public ActionResult EditHalls1(string sDate, string sHour, string hall) { string newHall = Request.Form["EditHalls"]; //string newHall = int.Parse(price_string); var moviesMandageObj = new CinemaDal(); Screenings s = (from x in moviesMandageObj.screenings where x.sDate.ToString().Equals(sDate.ToString()) && x.sHour.ToString().Equals(sHour.ToString()) && x.hall.ToString().Equals(hall.ToString()) select x).ToList <Screenings>()[0]; var screeen = (from x in moviesMandageObj.screenings where x.sDate.ToString().Equals(sDate.ToString()) && x.sHour.ToString().Equals(sHour.ToString()) select x).ToList <Screenings>(); Screenings newS = new Screenings(); if (screeen.Where(y => y.sDate == sDate && y.sHour == sHour && y.hall == newHall).Any()) { string text = "There is another screening at the same date and hour in this hall, try to change to another hall"; MessageBox.Show(text); } else if (!(moviesMandageObj.hall.Where(y => y.hall == newHall).Any())) { string text = "You are trying to change this screening to hall that does not exist in the cinema"; MessageBox.Show(text); } else { newS.movieName = s.movieName; newS.sDate = s.sDate; newS.sHour = s.sHour; newS.hall = newHall; moviesMandageObj.screenings.Remove(s); moviesMandageObj.SaveChanges(); moviesMandageObj.screenings.Add(newS); moviesMandageObj.SaveChanges(); } return(EditHalls()); }
public ActionResult EditPrice1(string movieName) { string price_string = Request.Form["EditPrice"]; int price = int.Parse(price_string); var moviesMandageObj = new CinemaDal(); Movies m = (from x in moviesMandageObj.movies where x.movieName.ToString().Contains(movieName.ToString()) select x).ToList <Movies>()[0]; Movies newM = new Movies(); newM.movieName = m.movieName; newM.movieName = m.movieName; newM.poster = m.poster; newM.previousPrice = m.currentPrice; newM.ageLimit = m.ageLimit; newM.category = m.category; newM.currentPrice = price; moviesMandageObj.movies.Remove(m); moviesMandageObj.SaveChanges(); moviesMandageObj.movies.Add(newM); moviesMandageObj.SaveChanges(); /* * Movies mov = newDal.movies.Find(movieId); * mov.previousPrice = mov.currentPrice; * mov.currentPrice = price;*/ return(EditPrice()); }
public ActionResult InsertMovies(Movies movieObj) { if (movieObj.movieName != null && movieObj.poster != null && movieObj.previousPrice != null && movieObj.currentPrice != null && movieObj.ageLimit != null && movieObj.category != null) { var newDal = new CinemaDal(); if (newDal.movies.Where(y => y.movieName == movieObj.movieName).Any()) { string text = "This movie is already exist!"; MessageBox.Show(text); return(View("InsertMovies")); } else { newDal.movies.Add(movieObj); newDal.SaveChanges(); // לדאוג לולדיציות } } else { string text = "There is values that stay empty, please full all the inputs"; MessageBox.Show(text); return(View("InsertMovies")); } return(RedirectToAction("Movies")); }
public ActionResult Login1() { string userNameGetter = Request.Form["userName"]; string passwordGetter = Request.Form["userPassword"]; var newDal = new CinemaDal(); foreach (var item in newDal.cart.ToList <Cart>()) // remove from cart while new user is loged in { newDal.cart.Remove(item); newDal.SaveChanges(); } //Users u = (from x in newDal.users where x.userName.ToString().Equals(userNameGetter) && x.userPassword.ToString().Equals(passwordGetter) select x).ToList<Users>().First(); if (newDal.users.Where(s => s.userName == userNameGetter && s.userPassword == passwordGetter && s.permission == "regular").Any()) { Session["login"] = "******"; return(RedirectToAction("Gallery", "Home")); } if (newDal.users.Where(s => s.userName == userNameGetter && s.userPassword == passwordGetter && s.permission == "admin").Any()) { return(RedirectToAction("AdminHome", "Admin")); } else { string text = "You are not a registered user, Please sign up before Login"; MessageBox.Show(text); } return(RedirectToAction("Login")); }
public ActionResult AddToCart(string movieName, string sDate, string sHour, string hall, string numOfRow, string numOfSeat) { var cartDb = new CinemaDal(); Cart addTtoCart = new Cart(); var isInCart = (from x in cartDb.cart where x.sDate.ToString().Contains(sDate) && x.sHour.ToString().Equals(sHour) && x.hall.ToString().Equals(hall) && x.numOfRow.ToString().Equals(numOfRow) && x.numOfSeat.ToString().Equals(numOfSeat) select x).ToList <Cart>(); if (isInCart.Where(y => y.sDate == sDate && y.sHour == sHour && y.numOfRow == numOfRow && y.numOfSeat == numOfSeat).Any()) { string text = "This seat is already in your cart, please try another one"; MessageBox.Show(text); } else { Screenings s = (from x in cartDb.screenings where x.sDate.ToString().Contains(sDate) && x.sHour.ToString().Equals(sHour) && x.hall.ToString().Equals(hall) select x).ToList <Screenings>()[0]; Movies m = (from tmp in cartDb.movies where s.movieName.Equals(tmp.movieName) select tmp).ToList <Movies>()[0]; //var t = (from x in cartDb.tickets where x.sDate.ToString().Contains(sDate) && x.sHour.ToString().Equals(sHour) && x.hall.ToString().Equals(hall) select x).ToList<Tickets>(); addTtoCart.hall = hall; addTtoCart.sDate = sDate; addTtoCart.sHour = sHour; addTtoCart.numOfRow = numOfRow; addTtoCart.numOfSeat = numOfSeat; addTtoCart.movieName = s.movieName; addTtoCart.price = m.currentPrice; cartDb.cart.Add(addTtoCart); cartDb.SaveChanges(); string text = "Your ticket has been successfully added to the cart"; MessageBox.Show(text); } return(Buy(movieName, sDate, sHour, hall)); }
public ActionResult EditSeats1(string numOfSeats, string hall) { string newNumOfSeat = Request.Form["EditSeats"]; //string newHall = int.Parse(price_string); var moviesMandageObj = new CinemaDal(); Hall h = (from x in moviesMandageObj.hall where x.hall.ToString().Equals(hall.ToString()) select x).ToList <Hall>()[0]; Hall newH = new Hall(); newH.hall = h.hall; newH.numOfSeats = newNumOfSeat; newH.numOfRows = h.numOfRows; moviesMandageObj.hall.Remove(h); moviesMandageObj.SaveChanges(); moviesMandageObj.hall.Add(newH); moviesMandageObj.SaveChanges(); return(EditSeats()); }
public ActionResult Delete(string movieName) { var moviesManageObj = new CinemaDal(); Movies m = (from x in moviesManageObj.movies where x.movieName.ToString().Contains(movieName.ToString()) select x).ToList <Movies>()[0]; moviesManageObj.movies.Remove(m); moviesManageObj.SaveChanges(); foreach (var item in moviesManageObj.screenings.ToList <Screenings>()) { if (item.movieName == movieName) { Screenings s = (from x in moviesManageObj.screenings where x.movieName.ToString().Contains(movieName.ToString()) select x).ToList <Screenings>()[0]; moviesManageObj.screenings.Remove(s); moviesManageObj.SaveChanges(); } } return(RedirectToAction("Movies")); }
public ActionResult DeleteFromCart(string sDate, string sHour, string hall, string numOfSeat, string numOfRow) { var newDal = new CinemaDal(); Cart c = (from x in newDal.cart where x.sDate.ToString().Equals(sDate.ToString()) && x.sHour.ToString().Equals(sHour.ToString()) && x.hall.ToString().Equals(hall.ToString()) && x.numOfSeat.ToString().Equals(numOfSeat.ToString()) && x.numOfRow.ToString().Equals(numOfRow.ToString()) select x).ToList <Cart>()[0]; newDal.cart.Remove(c); newDal.SaveChanges(); return(RedirectToAction("Cart")); }
public ActionResult PayDirectly(string movieName, string sDate, string sHour, string hall, string numOfRow, string numOfSeat) { var newDal = new CinemaDal(); Tickets t = new Tickets(); t.hall = hall; t.movieName = movieName; t.numOfRow = numOfRow; t.numOfSeat = numOfSeat; t.sDate = sDate; t.sHour = sHour; foreach (var item in newDal.cart.ToList <Cart>()) { // במידה ויש מישהו שמשלם ישיר, וקיים כרטיס כזה בעגלת קניות, הכרטיס ימחק מעגלת הקניות על-מנת שאותו מישהו שמשלם באופן ישיר, יוכל לשלם if (t.hall == item.hall && t.numOfRow == item.numOfRow && t.numOfSeat == item.numOfSeat && t.sDate == item.sDate && t.sHour == item.sHour) { newDal.cart.Remove(item); newDal.SaveChanges(); } } newDal.tickets.Add(t); newDal.SaveChanges(); return(View()); }
public ActionResult Payment1() { var newDal = new CinemaDal(); Tickets t = new Tickets(); int i = 0; foreach (var item in newDal.cart.ToList <Cart>()) { t.hall = item.hall; t.movieName = item.movieName; t.numOfRow = item.numOfRow; t.numOfSeat = item.numOfSeat; t.sDate = item.sDate; t.sHour = item.sHour; newDal.tickets.Add(t); newDal.SaveChanges(); t = new Tickets(); newDal.cart.Remove(item); newDal.SaveChanges(); } Random random = new Random(); int randNum = random.Next(0, 2); if (randNum == 0) { string text = "Your order has been successfully received"; MessageBox.Show(text); return(RedirectToAction("Gallery", "Home")); } else { string text = "The Credit card company declined your card, please try another one"; MessageBox.Show(text); return(View("Payment")); } }
public ActionResult SignUp1(Users userObj) { var newDal = new CinemaDal(); if (userObj != null) { if (newDal.users.Where(s => s.userName == userObj.userName).Any()) { string text = "This username is already exist, please choose another one"; MessageBox.Show(text); return(RedirectToAction("SignUp")); } newDal.users.Add(userObj); newDal.SaveChanges(); // לדאוג לולדיציות } return(RedirectToAction("Gallery")); }