public List <MovieModelDTO> GetAllMovies() { using (var context = new CinemaEntities()) { var allMovies = (from movie in context.Movies select new { MovieId = movie.MovieID, Title = movie.Title }).ToList(); List <MovieModelDTO> allMoviesToReturn = new List <MovieModelDTO>(); if (allMovies != null) { foreach (var item in allMovies) { MovieModelDTO movieRow = new MovieModelDTO() { MovieID = item.MovieId, Tilte = item.Title }; allMoviesToReturn.Add(movieRow); } return(allMoviesToReturn); } else { return(null); } } }
public void ShowMovies(DataGridView table) { using (CinemaEntities database = new CinemaEntities()) { table.DataSource = database.sp_showMovies().ToList(); } }
public void ShowAvgRating(DataGridView table, int movieID) { using (CinemaEntities database = new CinemaEntities()) { table.DataSource = database.sp_showAverageRatingMovie(movieID).ToList(); } }
public LoginWindowViewModel() { SignUpCommand = new RelayCommand(SignUpCommandExecute, null); SignInCommand = new RelayCommand(SignInCommandExecute, SignInCommandCanExecute); _database = new CinemaEntities(); }
public UserWindowViewModel() { _database = new CinemaEntities(); Messenger.Default.Register <string>(this, FillPhoneNumber, false); #region OrderTicketWindow Cities = _database.Cities.ToList(); Cinemas = new List <Cinemas>(); Films = new List <Films>(); Sessions = new List <MovieSession>(); Categories = _database.Categories.ToList(); ToOrderCommand = new RelayCommand(ToOrderCommandExecute, ToOrderCommandCanExecute); #endregion #region CheckOutFilmInfoWindow Films_FilmInfo = _database.Films.ToList(); CurrentReviewUrl = "https://youtube.com"; #endregion #region Weather WeatherImageSource = "https://i.ytimg.com/vi/aOPsmnexJi8/hqdefault.jpg"; DefineWeather(); #endregion #region Distance GetDistanceCommand = new RelayCommand(GetDistanceCommandExecute, GetDistanceCommandCanExecute); UserAddress = string.Empty; #endregion }
//Method that gets list of movies to which the specific user commented public IList <String> GetMoviesToWhichTheUserCommented(Guid userID) { IList <String> ListOfMovies = new List <String>(); using (var context = new CinemaEntities()) { var results = (from cm in context.Comments where cm.UserID == userID select new { MovieName = cm.Movie.Title }); if (results != null) { results = results.Distinct(); foreach (var item in results) { String row = item.MovieName; ListOfMovies.Add(row); } } } return(ListOfMovies); }
//Method that deletes movie from favorite list public bool RemoveMovieFromFavoriteList(Guid UserID, string movieTitle) { bool check; using (TransactionScope Trans = new TransactionScope()) { try { using (var context = new CinemaEntities()) { var results = (from fv in context.Favorites.Include("Movie") where fv.Movie.Title == movieTitle && fv.UserID == UserID select fv); if (results != null) { Favorite LineToDelete = (Favorite)results.First(); context.Favorites.DeleteObject(LineToDelete); context.SaveChanges(); } } } catch { check = false; Trans.Dispose(); return(check); } check = true; Trans.Complete(); return(check); } }
public ActionResult Login(USERS user) { using (CinemaEntities db = new CinemaEntities()) { byte[] client_password = Encoding.Default.GetBytes(user.PASSWORD); //utworzenie skrotu od pobranego hasla (SHA_1) using (var sha1 = SHA1.Create()) { byte[] client_password_sha1 = sha1.ComputeHash(client_password); string s_client_password_sha1 = Encoding.Default.GetString(client_password_sha1); user.PASSWORD = s_client_password_sha1; } var usr = db.USERS.Where(u => u.USER_LOGIN == user.USER_LOGIN && u.PASSWORD == user.PASSWORD).FirstOrDefault(); if (usr != null) { Session["USER_LOGIN"] = usr.USER_LOGIN.ToString(); Session["USER_NAME"] = usr.NAME.ToString(); usr.LAST_LOGIN = DateTime.Now; db.Entry(usr).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("", "Home")); } else { ModelState.AddModelError("", "Dane logowania są niepoprawne!"); } } return(View()); }
public IList <PerformanceModelDTO> GetPerformances(Guid theaterId) { IList <PerformanceModelDTO> performancesList = new List <PerformanceModelDTO>(); using (var context = new CinemaEntities()) { var performances = (from performance in context.Perfomances.Include("Room") where performance.TheaterID == theaterId select performance).ToList(); foreach (var perform in performances) { var performanceRow = new PerformanceModelDTO(); performanceRow.PerformanceID = perform.PerfomanceID; string date = perform.Date.ToString("yyyy'/'MM'/'dd"); performanceRow.Date = date; //(DateTime)perform.Date; TimeSpan time = (TimeSpan)perform.StartingTime; performanceRow.StartingTime = string.Format("{0:hh\\:mm}", time); // (TimeSpan)perform.StartingTime; performanceRow.Title = perform.Movie.Title; performanceRow.Price = perform.Price; performanceRow.RoomNumber = perform.Room.RoomNumber; performanceRow.Duration = perform.Duration;; performancesList.Add(performanceRow); } } return(performancesList); }
public List <MovieModelDTO> GetAllGenres() { using (var context = new CinemaEntities()) { var allGenre = (from genre in context.Genres select new { GenreName = genre.Name }).ToList(); List <MovieModelDTO> allGenresToReturn = new List <MovieModelDTO>(); if (allGenre != null) { foreach (var item in allGenre) { MovieModelDTO genreRow = new MovieModelDTO() { GenreName = item.GenreName }; allGenresToReturn.Add(genreRow); } return(allGenresToReturn); } else { return(null); } } }
public void ShowShowtimes(DataGridView table) { using (CinemaEntities database = new CinemaEntities()) { table.DataSource = database.SHOWTIME_VIEW.ToList(); } }
public List <MovieModelDTO> GetAllYears() { using (var context = new CinemaEntities()) { var allYears = (from movie in context.Movies orderby movie.Year ascending select new { MovieId = movie.MovieID, Year = movie.Year }).ToList(); List <MovieModelDTO> allYearsToReturn = new List <MovieModelDTO>(); if (allYears != null) { foreach (var item in allYears) { MovieModelDTO yearRow = new MovieModelDTO() { MovieID = item.MovieId, Year = item.Year }; allYearsToReturn.Add(yearRow); } return(allYearsToReturn); } else { return(null); } } }
public MovieModelDTO GetMovieByID(int movieID) { MovieModelDTO SelectedMovie = new MovieModelDTO(); using (var context = new CinemaEntities()) { var results = (from mv in context.Movies.Include("Genre") where mv.MovieID == movieID select mv); if (results != null) { foreach (var item in results) { SelectedMovie.MovieID = item.MovieID; SelectedMovie.Title = item.Title; SelectedMovie.GenreName = item.Genre.Name; SelectedMovie.Description = item.Description; SelectedMovie.Year = item.Year; } } } return(SelectedMovie); }
private void Window_Loaded(object sender, RoutedEventArgs e) { CinemaEntities ctx = new CinemaEntities(); string f, r, pl, pr, d, t, h; Билеты last = ctx.Билеты.ToList().Last(); f = ctx.Фильмы.FirstOrDefault(c => c.ID == (ctx.Сеансы.FirstOrDefault(s => s.ID == last.IDСеанса).IDФильма)).Название; r = last.яд.Value.ToString(); pl = last.Место.Value.ToString(); d = ctx.Сеансы.FirstOrDefault(s => s.ID == last.IDСеанса).Дата.Value.ToShortDateString(); t = ctx.Сеансы.FirstOrDefault(s => s.ID == last.IDСеанса).Время; h = ctx.Залы.FirstOrDefault(c => c.ID == (ctx.Сеансы.FirstOrDefault(s => s.ID == last.IDСеанса).IDЗала)).НомерЗала.Value.ToString(); Сеансы lastSeans = ctx.Сеансы.FirstOrDefault(s => s.ID == last.IDСеанса); pr = ctx.СтоимостьБилетов.FirstOrDefault(c => c.IDСеанса == lastSeans.ID).Стоимость.Value.ToString() + ".руб"; Film.Content = f.ToString(); Row.Content = r.ToString(); Place.Content = pl.ToString(); Price.Content = pr.ToString(); Date.Content = d.ToString(); Time.Content = t.ToString(); Hall.Content = h.ToString(); }
//Method that gets Performances by Theater public IList <UserPerformanceDTO> GetPerformancesByTheaterIDandMovieID(Guid TheaterID, int movieID) { IList <UserPerformanceDTO> ListOfPerformances = new List <UserPerformanceDTO>(); using (var context = new CinemaEntities()) { var results = (from pr in context.Perfomances.Include("Movie").Include("Theater") where pr.TheaterID == TheaterID && pr.MovieID == movieID select pr); if (results != null) { foreach (var item in results) { UserPerformanceDTO row = new UserPerformanceDTO(); row.performanceID = item.PerfomanceID; row.MovieTitle = item.Movie.Title; row.roomNumber = item.Room.RoomNumber; row.Date = item.Date.ToString("yyyy/MM/dd"); string hours = item.StartingTime.Hours.ToString(); if (hours.Length < 2) { hours = string.Format("{0}{1}", "0", hours); } string minutes = item.StartingTime.Minutes.ToString(); row.StartingTime = string.Format("{0}:{1}", hours, minutes); row.Duration = item.Duration; row.price = item.Price; ListOfPerformances.Add(row); } } } return(ListOfPerformances); }
public void ShowAllBookedTicketsView(DataGridView table) { using (CinemaEntities database = new CinemaEntities()) { table.DataSource = database.TICKET_VIEW.Where(x => x.Status == "Booked").ToList(); } }
//Method that updates comment public bool UpdateComment(UserCommentDTO UpdatedComment) { bool check = false; using (TransactionScope Trans = new TransactionScope()) { try { using (var context = new CinemaEntities()) { var results = (from cm in context.Comments where cm.CommentID == UpdatedComment.commentID select cm); if (results != null) { Comment CommentToUpdate = new Comment(); CommentToUpdate = (Comment)results.First(); CommentToUpdate.Content = UpdatedComment.Content; context.ObjectStateManager.ChangeObjectState(CommentToUpdate, System.Data.EntityState.Modified); context.SaveChanges(); } } } catch { check = false; Trans.Dispose(); return(check); } check = true; Trans.Complete(); return(check); } }
public void ShowRatings(DataGridView table, int customerID) { using (CinemaEntities database = new CinemaEntities()) { table.DataSource = database.sp_showCustomerRatings(customerID).ToList(); } }
//Method that removes comment public bool DeleteComment(int commentID) { bool check = false; using (TransactionScope Trans = new TransactionScope()) { try { using (var context = new CinemaEntities()) { var results = (from cm in context.Comments where cm.CommentID == commentID select cm); if (results != null) { Comment CommentToDelete = results.First(); context.Comments.DeleteObject(CommentToDelete); context.SaveChanges(); } } } catch { check = false; Trans.Dispose(); return(check); } check = true; Trans.Complete(); return(check); } }
public List <Genre> GetGenres() { using (CinemaEntities database = new CinemaEntities()) { return(database.Genre.ToList()); } }
//Method that gets all Ratings for specific user public IList <UserRatingDTO> GetAllUserRatings(Guid userID) { IList <UserRatingDTO> ListOfRatings = new List <UserRatingDTO>(); using (var context = new CinemaEntities()) { var results = (from rt in context.Ratings.Include("Movie") where rt.UserID == userID select rt); if (results != null) { foreach (var item in results) { UserRatingDTO row = new UserRatingDTO(); row.ratingID = item.RatingID; row.userID = userID.ToString(); row.movieID = item.MovieID; row.MovieTitle = item.Movie.Title; row.rate = item.Rate; ListOfRatings.Add(row); } } } return(ListOfRatings); }
public void SignUp(string login, string password, string firstName, string lastName, string birth, string email, string phone) { using (CinemaEntities database = new CinemaEntities()) { Customer newCustomer = database.Customer.Create(); newCustomer.Customer_ID = Convert.ToInt32(database.sp_getSeqCustomerID().FirstOrDefault()); newCustomer.Login = login; newCustomer.Password = password; newCustomer.First_Name = firstName; newCustomer.Last_Name = lastName; newCustomer.Birth = DateTime.Parse(birth); newCustomer.Email = email; newCustomer.Phone = phone; newCustomer.Role_ID = 1; // jeśli zajęty if (CustomerExist(login)) { MessageBox.Show("User name is already taken"); } // jeśli nie jest zajęty else { database.Customer.Add(newCustomer); database.SaveChanges(); MessageBox.Show("Account created"); } } }
public AboutPoster(Form mainForm, int filmId) { InitializeComponent(); this.MainForm = mainForm; this.FilmId = filmId; db = new CinemaEntities(); }
//Method that gets all Favorite movies of a specific user public IList <UserFavoriteMovieDTO> GetFavoriteMoviesByUser(Guid userID) { IList <UserFavoriteMovieDTO> ListOfMovies = new List <UserFavoriteMovieDTO>(); using (var context = new CinemaEntities()) { var results = (from fv in context.Favorites.Include("Movie") where fv.UserID == userID select fv); if (results != null) { foreach (var item in results) { UserFavoriteMovieDTO row = new UserFavoriteMovieDTO(); row.userID = userID.ToString(); row.movieID = item.MovieID; row.MovieTitle = item.Movie.Title; ListOfMovies.Add(row); } } } return(ListOfMovies); }
public AddFilm(Form mainForm, Panel posterPanel) { InitializeComponent(); MainForm = mainForm; FilmPanel = posterPanel; db = new CinemaEntities(); }
//Method that gets all Comments of specific user public IList <UserCommentDTO> GetAllUserComments(System.Guid userID) { IList <UserCommentDTO> ListOfComments = new List <UserCommentDTO>(); using (var context = new CinemaEntities()) { var results = (from com in context.Comments.Include("Movie") where com.UserID == userID select com); if (results != null) { foreach (var item in results) { UserCommentDTO row = new UserCommentDTO(); row.userID = userID.ToString(); row.commentID = item.CommentID; row.movieID = item.MovieID; row.Content = item.Content; row.MovieTitle = item.Movie.Title; ListOfComments.Add(row); } } } return(ListOfComments); }
public void ShowComments(DataGridView table, int movieID) { using (CinemaEntities database = new CinemaEntities()) { table.DataSource = database.sp_showCommentsMovie(movieID).ToList(); } }
//Method that gets the theaters by City public IList <UserTheaterDTO> GetTheatersByCity(String City, int movieID) { IList <UserTheaterDTO> ListOfTheaters = new List <UserTheaterDTO>(); using (var context = new CinemaEntities()) { var results = (from pr in context.Perfomances.Include("Theater") join ad in context.Addresses.Include("ObjectType") on pr.TheaterID equals ad.ObjectID where pr.MovieID == movieID where ad.City == City where ad.ObjectType.Description == "Theater" select new { TheaterID = pr.TheaterID, TheaterName = pr.Theater.Name, AddressTh = ad }); if (results != null) { foreach (var item in results) { UserTheaterDTO row = new UserTheaterDTO(); row.TheaterID = item.TheaterID; row.TheaterName = item.TheaterName; row.TheaterAddress = String.Format("str. {0}, {1}, phone number: {2}.", item.AddressTh.AddressLine1, item.AddressTh.City, item.AddressTh.Phone); ListOfTheaters.Add(row); } } } return(ListOfTheaters); }
//get list of for ddlProducerMovie MainMovie.aspx public List <MoviePersonDTO> GetProducers() { using (var context = new CinemaEntities()) { string cast = "producer"; var castmovie = (from moviePerson in context.PersonMovies where moviePerson.Person.PersonType.Description == cast select moviePerson).ToList(); if (castmovie.Count() > 0) { List <MoviePersonDTO> castPeopleToReturn = new List <MoviePersonDTO>(); foreach (var item in castmovie) { MoviePersonDTO castPeopleRow = new MoviePersonDTO() { FirstName = item.Person.FirstName + " " + item.Person.LastName, //Fiction for getting a person full name into a drop LastName = item.Person.LastName, // down list (Marat) }; castPeopleToReturn.Add(castPeopleRow); } return(castPeopleToReturn); } else { return(null); } } }
// Method gets movie Id and type of movie person ("Actor", "Director" etc..) and return list of people public List <MoviePersonDTO> GetMoviePeopleByMovieId(int movieId, string personType) { using (var context = new CinemaEntities()) { var moviePeople = (from moviePerson in context.PersonMovies // where moviePerson.MovieID == movieId && moviePerson.Person.PersonType.Description.Contains("actor") where moviePerson.MovieID == movieId && moviePerson.Person.PersonType.Description == personType select moviePerson).ToList(); if (moviePeople.Count() > 0) { List <MoviePersonDTO> moviePeopleToReturn = new List <MoviePersonDTO>(); foreach (var item in moviePeople) { MoviePersonDTO moviePeopleRow = new MoviePersonDTO() { FirstName = item.Person.FirstName, LastName = item.Person.LastName, BirthDate = (DateTime)item.Person.BirthDate, BirthPlace = item.Person.BirthPlace }; moviePeopleToReturn.Add(moviePeopleRow); } return(moviePeopleToReturn); } else { return(null); } } }