public ActionResult AddMovie(MovieAddEditModel model) { model.MovieName.LanguageID = ParseHelper.ToInt32(model.NameLanguageID); model.MovieName.IsDefault = true; //model.MovieArchive.ArchiveID = Parse.ToInt32(model.ArchiveID); //model.MovieArchive.Resolution = model.ArchiveResolution; //model.MovieArchive.FileExtension = model.ArchiveFileExtension; //model.MovieArchive.UserID = model. //insert movie first and get inserted id int movieId = MovieBL.Save(model.Movie, UserID); //save the name model.MovieName.MovieID = movieId; MovieNameBL.Save(model.MovieName, UserID); //if (model.ArchiveExists == true) //{ // //save the archive // model.MovieArchive.MovieID = movieId; // MovieArchiveBL.Save(model.MovieArchive, UserID); //} switch (model.Submit) { case "SubmitAndNavigateToMovie": return(RedirectToAction("DetailView", "Movie", new { id = movieId })); case "SubmitAndClearForm": default: return(RedirectToAction("AddMovie")); } }
public ActionResult EditMovie(int id) { MovieAddEditModel model = new MovieAddEditModel(); model.Movie = MovieBL.GetMovie(id); model.MovieName = MovieNameBL.GetAllDOByMovieID(id).SingleOrDefault(q => q.IsDefault == true); //model.MovieArchive = MovieArchiveBL.GetAllDOByMovieID(id).SingleOrDefault(); model.Languages.ToList().ForEach(q => q.Selected = false); model.Languages.Single(q => q.Value == model.MovieName.LanguageID.ToString()).Selected = true; //if (model.MovieArchive != null) //{ // model.ArchiveExists = true; // model.ResolutionList.ToList().ForEach(q => q.Selected = false); // model.ResolutionList.Single(q => q.Value == model.MovieArchive.Resolution).Selected = true; // model.FileExtensionList.ToList().ForEach(q => q.Selected = false); // model.FileExtensionList.Single(q => q.Value == model.MovieArchive.FileExtension).Selected = true; // model.Archives.ToList().ForEach(q => q.Selected = false); // model.Archives.Single(q => q.Value == model.MovieArchive.ArchiveID.ToString()).Selected = true; //} return(View(model)); }
// GET: Tickets/Details/5 public ActionResult CreateTicket() { int nooftickets = int.Parse(Request.QueryString["noofseats"]); int viewerId = int.Parse(Request.QueryString["viewerid"]); int showId = int.Parse(Request.QueryString["showid"]); int movieId = int.Parse(Request.QueryString["movieId"]); string seatnos = Request.QueryString["seatnumbers"]; ViewerProfileEntity viewer = ViewrProfilesBL.SearchViewerProfileByIdBL(viewerId); ShowEntity show = ShowsBL.SearchShowByIdBL(showId); MovyEntity movie = MovieBL.SearchMovieByIdBL(movieId); ScreenEntity screen = ScreenBL.SearchScreenByIdBL(show.ScreenId); ViewBag.ShowDate = show.ShowDate.ToShortDateString(); ViewBag.ShowId = show.ShowId; ViewBag.ViewerId = viewer.ViewersId; ViewBag.MovieName = movie.MovieName; ViewBag.Price = show.Price * nooftickets; ViewBag.NameOfCustomer = viewer.FirstName + " " + viewer.LastName; ViewBag.ScreenName = screen.ScreenName; ViewBag.noOfTickets = nooftickets; ViewBag.seatNos = seatnos; return(View()); }
private void btnStart_Click(object sender, EventArgs e) { //MOVIE LIST THINGS mListCurrent = MovieBL.GetAllImdbless(chkCheckPosterless.Checked).ToList( ); //mListCurrent = new List<MovieDO> ( ); //mListCurrent.Add ( MovieBL.GetMovie ( 1054 ) ); //int howManyDoYouWant = 1; //mListCurrent.RemoveRange( howManyDoYouWant, mListCurrent.Count - howManyDoYouWant ); mListWaiting = new List <MovieDO>( ); //MOVIE COUNT THINGS mCount = mListCurrent.Count; parseStatus.Minimum = 0; parseStatus.Maximum = mCount; parseStatus.Value = 0; //START THREAD Thread parseThread = new Thread(new ThreadStart(parseMovies)); parseThread.Start( ); setButtonEnabled(btnStart, false); }
public ActionResult ViewTicket(int id) { TicketEntity createTicket = new TicketEntity(); createTicket = TicketsBL.SearchTicketByIdBL(id); ViewerProfileEntity viewer = ViewrProfilesBL.SearchViewerProfileByIdBL(createTicket.ViewersId); ShowEntity show = ShowsBL.SearchShowByIdBL(createTicket.ShowId); MovyEntity movie = MovieBL.SearchMovieByIdBL(createTicket.MovieId); ScreenEntity screen = ScreenBL.SearchScreenByIdBL(show.ScreenId); ViewBag.ShowDate = show.ShowDate.ToShortDateString(); ViewBag.ShowId = show.ShowId; ViewBag.ViewerId = viewer.ViewersId; ViewBag.MovieName = movie.MovieName; ViewBag.Price = show.Price * createTicket.NoOfTickets; ViewBag.NameOfCustomer = viewer.FirstName + " " + viewer.LastName; ViewBag.ScreenName = screen.ScreenName; ViewBag.noOfTickets = createTicket.NoOfTickets; ViewBag.seatNos = createTicket.Seats; if (createTicket != null) { return(View()); } else { return(Redirect(string.Format("/Movies/ListAllMovies"))); } }
// GET: Movies/Details/5 public ActionResult DetailsMovie(int id) { MovyEntity movie = MovieBL.SearchMovieByIdBL(id); if (movie == null) { return(HttpNotFound()); } return(View(movie)); }
public ActionResult DeleteMovieConfirmed(int id) { bool isDeleted = false; isDeleted = MovieBL.DeleteMovieBL(id); if (isDeleted) { return(RedirectToAction("Index")); } return(HttpNotFound()); }
public ActionResult SearchAuto(MovyEntity movie) { List <SelectListItem> genreList = GenreBL.ViewAllGenreBL().Select(n => new SelectListItem { Value = n.GenreId.ToString(), Text = n.GenreName }).ToList();; var genreTip = new SelectListItem() { Value = null, Text = "-- genre --" }; genreList.Insert(0, genreTip); ViewBag.generList = new SelectList(genreList, "Value", "Text"); List <SelectListItem> languageList = LanguageBL.ViewAllLanguageBL().Select(n => new SelectListItem { Value = n.LanguageId.ToString(), Text = n.LanguageName }).ToList();; var languageTip = new SelectListItem() { Value = null, Text = "-- Language --" }; languageList.Insert(0, languageTip); ViewBag.langList = new SelectList(languageList, "Value", "Text"); ////Note : you can bind same list from database List <MovyEntityNew> ObjList = new List <MovyEntityNew>(); ObjList = MovieBL.GetAllMoviesBL(); ////Searching records from list using LINQ query //var movieList = (from N in ObjList // where N.MovieName.StartsWith(Prefix) || N.MovieName.StartsWith(Prefix.ElementAt(0).ToString().ToUpper()) // select new { N.MovieName }); //return Json(movieList, JsonRequestBehavior.AllowGet); var movieList = (from N in ObjList where N.MovieName.ToLower().Equals(movie.MovieName.ToLower()) select N); MovyEntityNew movieResult = movieList.FirstOrDefault(); if (movieResult != null) { string url = string.Format("/Movies/MovieDetails/" + movieResult.MovieId); return(Redirect(url)); } else { string url = string.Format("/Movies/ListAllMovies"); return(Redirect(url)); } }
//add view here // GET: Movies/Details/5 public ActionResult MovieDetails(int id) { MovyEntity movie = MovieBL.SearchMovieByIdBL(id); ViewBag.language = LanguageBL.SearchLanguageBL(movie.LanguageId).LanguageName; ViewBag.genre = GenreBL.SearchGenreBL(movie.GenreId).GenreName; movie.ReleaseDate = movie.ReleaseDate.Date; if (movie == null) { return(HttpNotFound()); } return(View(movie)); }
// GET: Movies/Delete/5 public ActionResult DeleteMovie(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} MovyEntity movie = MovieBL.SearchMovieByIdBL(id); if (movie == null) { return(HttpNotFound()); } return(View(movie)); }
// GET: Movies public ActionResult ListAllMovies(MovyEntityNew movie, MovyEntity movieFilter) { List <SelectListItem> genreList = GenreBL.ViewAllGenreBL().Select(n => new SelectListItem { Value = n.GenreId.ToString(), Text = n.GenreName }).ToList();; var genreTip = new SelectListItem() { Value = null, Text = "-- genre --" }; genreList.Insert(0, genreTip); ViewBag.generList = new SelectList(genreList, "Value", "Text"); List <SelectListItem> languageList = LanguageBL.ViewAllLanguageBL().Select(n => new SelectListItem { Value = n.LanguageId.ToString(), Text = n.LanguageName }).ToList();; var languageTip = new SelectListItem() { Value = null, Text = "-- Language --" }; languageList.Insert(0, languageTip); ViewBag.langList = new SelectList(languageList, "Value", "Text"); string username = Request.QueryString["username"]; string genrename = GenreBL.SearchGenreBL(movieFilter.GenreId).GenreName; string languagename = LanguageBL.SearchLanguageBL(movieFilter.LanguageId).LanguageName; List <MovyEntityNew> listMovies = MovieBL.GetAllMoviesBL(); var query = from item in listMovies where item.Genre.Equals(genrename) || movieFilter.GenreId == 0 where item.Language.Equals(languagename) || movieFilter.LanguageId == 0 select item; if (Session["Username"] != null && Session["ViewerId"] != null) { ViewBag.ViewerId = Session["ViewerId"]; return(View(query)); } else { string url = string.Format("/Users/LogIn"); return(Redirect(url)); } }
public ActionResult EditMovie(MovyEntity movy) { bool isUpdated = false; if (ModelState.IsValid) { isUpdated = MovieBL.UpdateMovieBL(movy); if (isUpdated) { return(RedirectToAction("Index")); } } return(View(movy)); }
public ActionResult EditMovie(MovieAddEditModel model) { int movieId = model.MovieId; MovieDO _movie = MovieBL.GetMovie(movieId); MovieNameDO _movieName = MovieNameBL.GetAllDOByMovieID(movieId).SingleOrDefault(q => q.IsDefault == true); //MovieArchiveDO _movieArchive = MovieArchiveBL.GetAllDOByMovieID(movieId).SingleOrDefault(); //if (_movieArchive == null) _movieArchive = new MovieArchiveDO() { MovieID = movieId }; _movieName.LanguageID = ParseHelper.ToInt32(model.NameLanguageID); _movieName.Name = model.MovieName.Name; //_movieArchive.ArchiveID = Parse.ToInt32(model.ArchiveID); //_movieArchive.Resolution = model.ArchiveResolution; //_movieArchive.FileExtension = model.ArchiveFileExtension; //_movieArchive.Path = model.MovieArchive.Path; //if imdbid is changed, we need to reset imdb things first. string previousImdbId = _movie.ImdbID; if (string.IsNullOrEmpty(previousImdbId) == false && model.Movie.ImdbID != previousImdbId) { MovieBL.ResetImdbInformation(model.MovieId); _movie = MovieBL.GetMovie(movieId); _movie.ImdbID = model.Movie.ImdbID; } //save movie MovieBL.Save(_movie, UserID); //save the name MovieNameBL.Save(_movieName, UserID); //if (model.ArchiveExists == true) //{ // //save the archive // MovieArchiveBL.Save(_movieArchive, UserID); //} switch (model.Submit) { case "SubmitAndNavigateToMovie": return(RedirectToAction("DetailView", "Movie", new { id = movieId })); case "SubmitAndClearForm": default: return(RedirectToAction("AddMovie")); } }
public ActionResult Index(BrowseViewModel model) { model.CurrentPage = 1; model.MovieTypes = TypeBL.GetAllDO().OrderBy(q => q.Name).ToList(); var movieList = MovieBL.GetAllAsDO(); //save filter to session Session["BrowseFilters"] = model.Filters; //do the filtering movieList = model.Filters.DoFilter(movieList, UserID); model.MovieList = movieList.OrderBy(q => q.OriginalName).ToList(); return(View(model)); }
public ActionResult Index(int page = 1) { BrowseViewModel model = new BrowseViewModel(); model.MovieTypes = TypeBL.GetAllDO().OrderBy(q => q.Name).ToList(); model.MovieList = MovieBL.GetAllAsDO().OrderBy(q => q.OriginalName).ToList(); model.CurrentPage = page; if (Session["BrowseFilters"] != null) { model.Filters = (FiltersForPage)Session["BrowseFilters"]; model.MovieList = model.Filters.DoFilter(model.MovieList, UserID).OrderBy(q => q.OriginalName).ToList(); } else { model.Filters = new Filtering.FiltersForPage(); } return(View(model)); }
public ActionResult CreateTicket(TicketEntity ticket) { int nooftickets = int.Parse(Request.QueryString["noofseats"]); int viewerId = int.Parse(Request.QueryString["viewerid"]); int showId = int.Parse(Request.QueryString["showid"]); int movieId = int.Parse(Request.QueryString["movieId"]); string seatnos = Request.QueryString["seatnumbers"]; ViewerProfileEntity viewer = ViewrProfilesBL.SearchViewerProfileByIdBL(viewerId); ShowEntity show = ShowsBL.SearchShowByIdBL(showId); MovyEntity movie = MovieBL.SearchMovieByIdBL(movieId); ScreenEntity screen = ScreenBL.SearchScreenByIdBL(show.ScreenId); TicketEntity createTicket = new TicketEntity(); createTicket.NoOfTickets = nooftickets; createTicket.ShowId = showId; ViewBag.MovieName = movie.MovieName; createTicket.Price = show.Price * nooftickets; createTicket.ViewersId = viewer.ViewersId; createTicket.TransactionDate = DateTime.Now.Date; createTicket.MovieId = movie.MovieId; createTicket.Seats = seatnos; if (ModelState.IsValid) { var IsAdded = TicketsBL.CreateTicketBL(createTicket); if (IsAdded) { return(Redirect(string.Format("/Payments/CompletePayment"))); } else { return(Redirect(string.Format("/SeatLayout/SelectSeatsView"))); } } else { return(Redirect(string.Format("/SeatLayout/SelectSeatsView"))); } }
public ActionResult AddMovie(MovyEntity movy) { List <SelectListItem> genreList = GenreBL.ViewAllGenreBL().Select(n => new SelectListItem { Value = n.GenreId.ToString(), Text = n.GenreName }).ToList();; var genreTip = new SelectListItem() { Value = null, Text = "--- select genre ---" }; genreList.Insert(0, genreTip); ViewBag.generList = new SelectList(genreList, "Value", "Text"); List <SelectListItem> languageList = LanguageBL.ViewAllLanguageBL().Select(n => new SelectListItem { Value = n.LanguageId.ToString(), Text = n.LanguageName }).ToList();; var languageTip = new SelectListItem() { Value = null, Text = "--- select Language ---" }; languageList.Insert(0, languageTip); ViewBag.langList = new SelectList(languageList, "Value", "Text"); bool isAdded = false; if (ModelState.IsValid) { isAdded = MovieBL.AddMovieBL(movy); if (isAdded) { return(RedirectToAction("Index")); } } return(View(movy)); }
public MovieController(IMovieManagementUoW db) { _bl = new MovieBL(db); }
//below are movie mehtods public ActionResult Index() { List <MovyEntityNew> listMovie = MovieBL.GetAllMoviesBL(); return(View(listMovie)); }
private void getMovieInfoByIdAndSave(string imdbId, MovieDO movie, TextWriter tw, DateTime start) { ImdbModel imdbInfo = new ImdbModel( ); try { imdbInfo = ImdbHelper.getMovieInformation(imdbId, tw, start); logHelper.logLine(tw, "Imdb information parsed successfully. Starting operation 'Basic Info'"); #region Basic Info (not updated in db yet) if (string.IsNullOrEmpty(movie.ImdbID)) { movie.ImdbID = imdbId; } if (string.IsNullOrEmpty(movie.ImdbPoster) && !string.IsNullOrEmpty(imdbInfo.picturePath)) { string savePath = getSavePath( ); string fileName = FileSystemHelper.prepareFileNameForPicture(imdbInfo.picturePath.Substring(imdbInfo.picturePath.LastIndexOf('/')), new MovieNameModel { OriginalName = movie.OriginalName }, savePath); WebRequestHelper.Download(imdbInfo.picturePath, savePath + fileName); movie.ImdbPoster = fileName; } movie.ImdbRating = imdbInfo.imdbRating; if (movie.Year == null || movie.Year == 0) { movie.Year = imdbInfo.year; } #endregion Basic Info logHelper.logLine(tw, "Basic Info inserted"); logHelper.logLine(tw, "Starting operation 'Genres'"); #region types if (MovieTypeBL.GetAllByMovieID(movie.ID).Count() < 1) { try { if (imdbInfo.genres != null) { foreach (string item in imdbInfo.genres) { if (allTypes.ContainsKey(item)) { MovieTypeBL.Save(new MovieTypeDO( ) { MovieID = movie.ID, TypeID = allTypes[item] }, 1); } else { int currentID = TypeBL.Save(new MArchive.Domain.Lookup.TypeDO( ) { Name = item }, 1).ID; //MovieTypeBL.Save( movie.ID, item, 1 ); MovieTypeBL.Save(new MovieTypeDO( ) { MovieID = movie.ID, TypeID = currentID }, 1); allTypes.Add(item, currentID); } } } logHelper.logLine(tw, "Genres inserted"); } catch (Exception ex) { logHelper.logLine(tw, "Genres could not be inserted."); logHelper.logException(tw, ex); logHelper.logLine(tw); } } #endregion types logHelper.logLine(tw, "Starting operation 'Actors'"); #region actors if (MovieActorBL.GetAllByMovieID(movie.ID).Count( ) < 1) { try { if (imdbInfo.cast != null) { foreach (string item in imdbInfo.cast) { if (allActors.ContainsKey(item)) { MovieActorBL.Save(new MovieActorDO( ) { MovieID = movie.ID, ActorID = allActors[item] }, 1); } else { int currentID = ActorBL.Save(new MArchive.Domain.Lookup.ActorDO( ) { Name = item }, 1).ID; MovieActorBL.Save(new MovieActorDO( ) { MovieID = movie.ID, ActorID = currentID }, 1); allActors.Add(item, currentID); } } } logHelper.logLine(tw, "Actors inserted"); } catch (Exception ex) { logHelper.logLine(tw, "Actors could not be inserted."); logHelper.logException(tw, ex); logHelper.logLine(tw); } } #endregion actors logHelper.logLine(tw, "Starting operation 'Languages'"); #region languages if (MovieLanguageBL.GetAllByMovieID(movie.ID).Count( ) < 1) { try { if (imdbInfo.languages != null) { foreach (string item in imdbInfo.languages) { if (allLanguages.ContainsKey(item)) { MovieLanguageBL.Save(new MovieLanguageDO( ) { MovieID = movie.ID, LanguageID = allLanguages[item] }, 1); } else { int currentID = LanguageBL.Save(new MArchive.Domain.Lookup.LanguageDO( ) { Name = item }, 1).ID; MovieLanguageBL.Save(new MovieLanguageDO( ) { MovieID = movie.ID, LanguageID = currentID }, 1); allLanguages.Add(item, currentID); } } } logHelper.logLine(tw, "Languages inserted"); } catch (Exception ex) { logHelper.logLine(tw, "Languages could not be inserted."); logHelper.logException(tw, ex); logHelper.logLine(tw); } } #endregion languages logHelper.logLine(tw, "Starting operation 'Directors'"); #region directors if (MovieDirectorBL.GetAllByMovieID(movie.ID).Count( ) < 1) { try { if (imdbInfo.directors != null) { foreach (string item in imdbInfo.directors) { if (allDirectors.ContainsKey(item)) { MovieDirectorBL.Save(new MovieDirectorDO( ) { MovieID = movie.ID, DirectorID = allDirectors[item] }, 1); } else { int currentID = DirectorBL.Save(new MArchive.Domain.Lookup.DirectorDO( ) { Name = item }, 1).ID; MovieDirectorBL.Save(new MovieDirectorDO( ) { MovieID = movie.ID, DirectorID = currentID }, 1); allDirectors.Add(item, currentID); } } } logHelper.logLine(tw, "Directors inserted"); } catch (Exception ex) { logHelper.logLine(tw, "Directors could not be inserted."); logHelper.logException(tw, ex); logHelper.logLine(tw); } } #endregion directors logHelper.logLine(tw, "Starting operation 'Writers'"); #region writers if (MovieWriterBL.GetAllByMovieID(movie.ID).Count( ) < 1) { try { if (imdbInfo.writers != null) { foreach (string item in imdbInfo.writers) { if (allWriters.ContainsKey(item)) { MovieWriterBL.Save(new MovieWriterDO( ) { MovieID = movie.ID, WriterID = allWriters[item] }, 1); } else { int currentID = WriterBL.Save(new MArchive.Domain.Lookup.WriterDO( ) { Name = item }, 1).ID; MovieWriterBL.Save(new MovieWriterDO( ) { MovieID = movie.ID, WriterID = currentID }, 1); allWriters.Add(item, currentID); } } } logHelper.logLine(tw, "Writers inserted"); } catch (Exception ex) { logHelper.logLine(tw, "Writers could not be inserted."); logHelper.logException(tw, ex); logHelper.logLine(tw); } } #endregion writers logHelper.logLine(tw, "Updating 'movie' table"); movie.ImdbParsed = true; movie.ImdbLastParseDate = movie.UpdateDate = DateTime.Now; MovieBL.Save(movie, 1); logHelper.logLine(tw, "Table update successful"); } catch (Exception ex) { logHelper.logException(tw, ex); } }
public void Ticket(User us) { Console.Clear(); string row1 = "====================================================================="; string row2 = "---------------------------------------------------------------------"; Console.WriteLine(row1); Console.WriteLine("Đặt vé."); Console.WriteLine(row2); Console.WriteLine("[Danh sách Phim]\n"); MovieBL mbl = new MovieBL(); string[] properties = { "MovieId", "MovieName", "MovieCategory", "MovieTime", "MovieDateStart", "MovieDateEnd" }; string[] cols = { "Mã phim", "Tên phim", "Thể loại", "Thời lượng(Phút)", "Ngày bắt đầu", "Ngày kết thúc" }; List <Movie> movies = mbl.GetMoviesByCineIdAndDateNow(us.Cine.CineId); cine = cbl.GetCinemaByCineId(us.Cine.CineId); DisplayTableData(movies, properties, cols, "dd/MM/yyyy"); Console.WriteLine(row1); Console.Write("\nChọn phim(theo mã): "); sche.MovieId = input(Console.ReadLine()); while (mbl.GetMovieByMovieId(sche.MovieId) == null) { Console.Write("Không có mã này, mời bạn nhập lại: "); sche.MovieId = input(Console.ReadLine()); } movie = mbl.GetMovieByMovieId(sche.MovieId); List <Schedule> ls = sbl.GetSchedulesByMovieId(sche.MovieId); List <ScheduleDetail> lsd = new List <ScheduleDetail>(); foreach (var itemListSchedule in ls) { List <ScheduleDetail> newlsdz = sdbl.GetScheduleDetailsByScheIdAndTimeNow(itemListSchedule.ScheId); foreach (var itemListScheduleDetail in newlsdz) { lsd.Add(itemListScheduleDetail); } } if (lsd.Count == 0) { while (true) { Console.Write("Không còn lịch chiếu cho phim bạn chọn trong ngày hôm nay. Bạn có muốn chọn phim khác?(C/K)"); string choice = Console.ReadLine(); switch (choice) { case "C": Ticket(us); return; case "c": Ticket(us); return; case "K": mn.menuStaff(us); return; case "k": mn.menuStaff(us); return; default: continue; // break; } } } Console.Clear(); Console.WriteLine(row1); Console.WriteLine("Đặt vé."); Console.WriteLine(row2); Console.WriteLine("[Danh sách lịch chiếu]"); int count = 0; // lsd.Sort( (l,r) => l.SchedTimeStart.CompareTo(r.SchedTimeStart) ); // lsd.Sort((x, y) => DateTime.Compare(x.SchedTimeStart, y.SchedTimeStart)); // foreach (var item in lsd) // { // count++; // Schedule schez = new Schedule(); // schez = sbl.GetScheduleByScheId(itemlsd.ScheId); // Room rooms = rbl.GetRoomByRoomId(schez.RoomId); // Console.WriteLine(count + ". Bắt đầu từ: " + itemlsd.SchedTimeStart?.ToString("HH:mm") + " -> " + itemlsd.SchedTimeEnd?.ToString("HH:mm") + " Tại phòng: " + rooms.RoomName); // } ConsoleManager cm = new ConsoleManager(); // List<ScheduleDetail> newlsd = new List<ScheduleDetail>(); for (int i = 0; i < lsd.Count - 1; i++) { for (int j = i + 1; j < lsd.Count; j++) { int time1 = cm.TimeToInt(lsd[i].SchedTimeStart?.ToString("HH:mm")); int time2 = cm.TimeToInt(lsd[j].SchedTimeStart?.ToString("HH:mm")); // Console.WriteLine(time1+" "+time2); if (time1 > time2) { ScheduleDetail newsd = new ScheduleDetail(); newsd = lsd[i]; lsd[i] = lsd[j]; lsd[j] = newsd; } } // newlsd.Add(lsd[i]); } foreach (var itemlsd in lsd) { count++; Schedule schez = new Schedule(); schez = sbl.GetScheduleByScheId(itemlsd.ScheId); Room rooms = rbl.GetRoomByRoomId(schez.RoomId); Console.WriteLine(count + ". Bắt đầu từ: " + itemlsd.SchedTimeStart?.ToString("HH:mm") + " -> " + itemlsd.SchedTimeEnd?.ToString("HH:mm") + " Tại phòng: " + rooms.RoomName); } Console.WriteLine(row1); Console.Write("Chọn lịch chiếu (theo số thứ tự): "); int scheno = input(Console.ReadLine()); while (scheno > lsd.Count) { Console.Write("Chọn sai lịch chiếu, mời nhập lại: "); scheno = input(Console.ReadLine()); } int?schedId = lsd[scheno - 1].SchedId; sched = sdbl.GetScheduleDetailBySchedId(schedId); string seatStr = null; string[] seat; Console.Clear(); while (true) { Console.WriteLine(row1); Console.WriteLine("Đặt vé"); Console.WriteLine(row2); Console.WriteLine("[Bản đồ phòng chiếu]"); try { // Console.WriteLine(ChoiceSeats(sched)); seatStr = ChoiceSeats(sched); seat = seatStr.Split(","); } catch (System.Exception) { seat = null; } if (seat == null) { Console.Clear(); Console.WriteLine("KHÔNG TÌM THẤY GHẾ !!!"); continue; } else if (seat[0] == "same") { Console.Clear(); Console.WriteLine("BẠN NHẬP SỐ GHẾ TRÙNG NHAU !!!"); continue; } else { break; } } // foreach (var item in seat) // { // Console.WriteLine(item); // } // Console.ReadKey(); foreach (var itemls in ls) { if (itemls.ScheId == sched.ScheId) { sche = itemls; } } // Console.ReadKey(); Room room = new Room(); room = rbl.GetRoomByRoomId(sche.RoomId); // Console.WriteLine(room.RTName); List <PriceSeatOfRoomType> lpsort = psortbl.GetPriceSeatsOfRoomTypeByRTName(room.RTName); // PriceSeatOfRoomType psort = null; List <PriceSeatOfRoomType> lpsort1 = new List <PriceSeatOfRoomType>(); // Console.Write(seat[0].ToString()); foreach (var itemlpsort in lpsort) { foreach (var item in seat) { // Console.WriteLine(itemlpsort.st); // Console.WriteLine(item); if (itemlpsort.STType == item[0].ToString()) { // psort = new PriceSeatOfRoomType(itemlpsort.STType,itemlpsort.RTName,itemlpsort.Price); // psort.STType = itemlpsort.STType; // psort.RTName = itemlpsort.RTName; // psort.Price = itemlpsort.Price; lpsort1.Add(new PriceSeatOfRoomType(itemlpsort.RTName, itemlpsort.STType, itemlpsort.Price)); } } } Console.Clear(); Console.WriteLine(row1); Console.WriteLine("Đặt vé"); Console.WriteLine(row2); Console.WriteLine("[Thông tin vé đã chọn]"); double price = 0; Console.WriteLine("Phim: {0}", movie.MovieName); Console.WriteLine("Thời gian chiếu: {0} - {0} -> {1}", sched.SchedTimeStart?.ToString("dd/MM/yyyy"), sched.SchedTimeStart?.ToString("HH:mm"), sched.SchedTimeEnd?.ToString("HH:mm")); Console.WriteLine("Các ghế đã chọn: {0}", seatStr); for (int i = 0; i < lpsort1.Count; i++) { price += lpsort1[i].Price; } Console.WriteLine(row1); Console.WriteLine("Tổng tiền vé: {0}", pricevalid(price)); while (true) { Console.Write("Xác nhận mua vé?(C/K)"); string choice = Console.ReadLine(); switch (choice) { case "C": tbl.SellTicket(sched); break; case "c": tbl.SellTicket(sched); break; case "K": break; case "k": break; default: continue; // break; } break; } Console.Write("Nhập số tiền khách hàng trả(đồng): "); double cusmoney; while (true) { try { cusmoney = Convert.ToDouble(Console.ReadLine()); if (cusmoney <= 0) { Console.Write("Số tiền trả phải lớn hơn 0, mời bạn nhập lại: "); continue; } if (cusmoney < price) { Console.Write("Số tiền nhập không đủ, mời bạn nhập lại: "); continue; } if (cusmoney > 999999999) { Console.Write("Số tiền quá lớn, mời bạn nhập lại: "); continue; } } catch { Console.Write("Bạn phải nhập số tiền bằng số, mời nhập lại số tiền khách hàng trả(đồng): "); continue; } break; } if ((cusmoney - price) > 0) { Console.WriteLine("Tiền trả lại: {0}", pricevalid(cusmoney - price)); } Console.WriteLine(row1); Console.WriteLine("Thanh toán thành công!!!\nBấm phím bất kì để in vé"); Console.ReadKey(); Console.Clear(); for (int i = 0; i < lpsort1.Count; i++) { PrintTicket(sched, sche, room, movie, lpsort1[i], us, cine, seat[i]); } Console.WriteLine("In vé thành công!!!\nBấm phím bất kì để thoát"); Console.ReadKey(); Console.Clear(); mn.menuStaff(us); }
public MovieController() //Constructor { movieBL = new MovieBL(); categoryBL = new CategoryBL(); }
public ActionResult DetailView(int id) { MovieDetailDO movie = MovieBL.GetMovieWithDetails(id, UserID); return(View(movie)); }
public void CreateSchedule(User us) { Console.Clear(); string row1 = "====================================================================="; string row2 = "---------------------------------------------------------------------"; Console.WriteLine(row1); Console.WriteLine("Tạo lịch chiếu phim."); Console.WriteLine(row2); Console.WriteLine("[Danh sách Phim]\n"); MovieBL mbl = new MovieBL(); string[] properties = { "MovieId", "MovieName", "MovieCategory", "MovieTime", "MovieDateStart", "MovieDateEnd" }; string[] cols = { "Mã phim", "Tên phim", "Thể loại", "Thời lượng(Phút)", "Ngày bắt đầu", "Ngày kết thúc" }; List <Movie> movies = mbl.GetMoviesByCineId(us.Cine.CineId); // cine = cbl.GetCinemaByCineId(us.Cine.CineId); cs.DisplayTableData(movies, properties, cols, "dd/MM/yyyy"); Console.WriteLine(row1); Console.Write("\nChọn phim(theo mã): "); sche.MovieId = cs.input(Console.ReadLine()); while (mbl.GetMovieByMovieId(sche.MovieId) == null) { Console.Write("Không có mã này, mời bạn nhập lại: "); sche.MovieId = cs.input(Console.ReadLine()); } cine = us.Cine; Console.Clear(); List <ScheduleDetail> lsd = null; int? scheNewId; ScheduleBL sbl = new ScheduleBL(); Schedule scheNew = null; while (true) { // row1 = "========================================"; // row2 = "----------------------------------------"; Console.WriteLine(row1); Console.WriteLine("Tạo lịch chiếu phim."); Console.WriteLine(row2); Console.WriteLine("[Danh sách phòng]\n"); string[] proper = { "RoomId", "RoomName", "RTName" }; string[] col = { "Mã phòng", "Tên phòng", "Loại phòng" }; lr = rbl.GetRoomsByCineId(1); cs.DisplayTableData(lr, proper, col, null); Console.WriteLine(row1); Console.Write("\nChọn phòng(theo mã): "); sche.RoomId = cs.input(Console.ReadLine()); while (rbl.GetRoomByRoomId(sche.RoomId) == null) { Console.Write("Không có mã này, mời bạn nhập lại: "); sche.RoomId = cs.input(Console.ReadLine()); } // while (sbl.GetScheduleByMovieIdAndRoomId(sche.MovieId, sche.RoomId) != null) // { // Console.Write("Trùng lịch chiếu, mời bạn nhập lại: "); // sche.RoomId = cs.input(Console.ReadLine()); // while (rbl.GetRoomByRoomId(sche.RoomId) == null) // { // Console.Write("Không có mã này, mời bạn nhập lại: "); sche.RoomId = cs.input(Console.ReadLine()); // } // } scheNew = sbl.GetScheduleByMovieIdAndRoomId(sche.MovieId, sche.RoomId); if (scheNew == null) { scheNewId = null; } else { scheNewId = scheNew.ScheId; } movie = mbl.GetMovieByMovieId(sche.MovieId); room = rbl.GetRoomByRoomId(sche.RoomId); lsd = DisplayTime(movie, room, scheNew); // Console.Write("Không tìm thấy khung giờ hoặc trùng, bạn có muốn chọn lại?(C/K)"); // string choice = Console.ReadLine(); // switch (choice) // { // case "C": // scheNew = sbl.GetScheduleByMovieIdAndRoomId(sche.MovieId, sche.RoomId); // movie = mbl.GetMovieByMovieId(sche.MovieId); // room = rbl.GetRoomByRoomId(sche.RoomId); // lsd = DisplayTime(movie, room, scheNew); // break; // case "c": // scheNew = sbl.GetScheduleByMovieIdAndRoomId(sche.MovieId, sche.RoomId); // movie = mbl.GetMovieByMovieId(sche.MovieId); // room = rbl.GetRoomByRoomId(sche.RoomId); // lsd = DisplayTime(movie, room, scheNew); // break; // case "K": // mn.menuManager(us); // return; // case "k": // mn.menuManager(us); // return; // default: // continue; // // break; // } if (lsd != null) { break; } Console.Clear(); Console.WriteLine("Phim: {0} tại phòng: {1} đã đủ suất chiếu !", movie.MovieName, room.RoomName); } Console.Clear(); Console.WriteLine(row1); Console.WriteLine("Tạo lịch chiếu phim."); Console.WriteLine(row2); Console.WriteLine("[Chi tiết lịch chiếu]\n"); Console.WriteLine("Bộ phim: " + movie.MovieName); Console.WriteLine("Chiếu tại rạp: " + cine.CineName); Console.WriteLine("Chiếu tại phòng: " + room.RoomName); Console.WriteLine("Trong các khung giờ lặp mỗi ngày từ ngày {0} - {1} cụ thể như sau: ", movie.MovieDateStart.ToString("dd/MM/yyyy"), movie.MovieDateEnd.ToString("dd/MM/yyyy")); int count = 1; string timeline = ""; if (scheNew != null) { timeline = scheNew.ScheTimeline; } for (int i = 1; i < lsd.Count - 1; i++) { if (lsd[0].SchedTimeStart?.ToString("HH:mm") == lsd[i].SchedTimeStart?.ToString("HH:mm")) { break; } count++; } for (int i = 0; i < count; i++) { try { Console.WriteLine("{0}.{1} -> {2}", i + 1, lsd[i].SchedTimeStart?.ToString("HH:mm"), lsd[i].SchedTimeEnd?.ToString("HH:mm")); if (timeline == "") { timeline = timeline + lsd[i].SchedTimeStart?.ToString("HH:mm"); } else { timeline = timeline + ", " + lsd[i].SchedTimeStart?.ToString("HH:mm"); } } catch (System.Exception) { } } // foreach (var item in lsd) // { // if (Schedule) // { // } // { // Console.WriteLine("{0}.{1} {2} -> {3}", count, item.SchedTimeEnd?.ToString("dd/MM/yyyy"), item.SchedTimeStart?.ToString("HH:mm"), item.SchedTimeEnd?.ToString("HH:mm")); // } // if (timeline == "") // { // timeline = timeline + item.SchedTimeStart?.ToString("HH:mm"); // } // else // { // timeline = timeline + ", " + item.SchedTimeStart?.ToString("HH:mm"); // } // count++; // } sche = new Schedule(scheNewId, 0, null, timeline, sche.RoomId, sche.MovieId, lsd); Console.WriteLine(row1); while (true) { Console.Write("Xác nhận tạo lịch chiếu?(C/K)"); string choice = Console.ReadLine(); switch (choice) { case "C": sbl.CreateSchedule(sche); break; case "c": sbl.CreateSchedule(sche); break; case "K": break; case "k": break; default: continue; // break; } break; } Console.Clear(); mn.menuManager(us); }