public static bool IsScreeningExisting(int auditoriumId, DateTime date) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Screenings.Any(s => s.AuditoriumId == auditoriumId && s.Start == date)); } }
public int GetMovieId(string movieName, int releaseYear) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Movies.First(m => m.Name == movieName && m.ReleaseYear == releaseYear).Id); } }
public List <Auditorium> GetAudtitoriums(int cinemaId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.Find(cinemaId).Auditoriums.ToList()); } }
public Town GetTown(string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Towns.FirstOrDefault(t => t.Name == townName)); } }
public bool IsTownExisting(string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Towns.Any(t => t.Name == townName)); } }
public bool isUsernameExisting(string username) { using (var db = new SoftCinemaContext()) { return(db.Users.Any(u => u.Username == username)); } }
public static List <Actor> GetAllActors() { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Actors.ToList()); } }
public static string[] GetCinemasNamesBySelectedTown(string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.Where(c => c.Town.Name == townName).Select(c => c.Name).ToArray()); } }
public static Cinema GetCinema(string cinemaName, string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.Include(c => c.Town).First(c => c.Name == cinemaName && c.Town.Name == townName)); } }
public static int GetCinemaId(string cinemaName, int townId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.First(c => c.Name == cinemaName && c.TownId == townId).Id); } }
public static List <Cinema> GetAllCinemas() { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.ToList()); } }
public static void RemoveCinema(string cinemaName, string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { Cinema cinema = context.Cinemas.FirstOrDefault(c => c.Name == cinemaName && c.Town.Name == townName); var auditoriums = cinema.Auditoriums.ToList(); foreach (var auditorium in auditoriums) { var screenings = auditorium.Screenings.ToList(); foreach (var screening in screenings) { var tickets = screening.Tickets.ToList(); foreach (var ticket in tickets) { context.Tickets.Remove(ticket); } context.Screenings.Remove(screening); } var seats = auditorium.Seats.ToList(); foreach (var seat in seats) { context.Seats.Remove(seat); } context.Auditoriums.Remove(auditorium); } context.Cinemas.Remove(cinema); context.SaveChanges(); } }
public static bool IsCinemaExistingByTownName(string cinemaName, string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.Any(c => c.Name == cinemaName && c.Town.Name == townName)); } }
public Category GetCategory(string categoryName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Categories.FirstOrDefault(c => c.Name == categoryName)); } }
public List <User> GetUsers() { using (var db = new SoftCinemaContext()) { return(db.Users.ToList()); } }
public static Cinema GetCinemaById(int cinemaId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.Find(cinemaId)); } }
public string GetPassword(string username) { using (var db = new SoftCinemaContext()) { return(db.Users.FirstOrDefault(u => u.Username == username).PasswordHash); } }
public static bool IsCinemaExisting(string cinemaName, int townId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Cinemas.Any(c => c.Name == cinemaName && c.TownId == townId)); } }
private void SeedEmployees(SoftCinemaContext context) { User employee1 = new User() { Username = "******", PasswordHash = PasswordHasher.ComputeHash("123", PasswordHasher.Supported_HA.SHA512, null), Email = "*****@*****.**", Role = Role.Employee }; User employee2 = new User() { Username = "******", PasswordHash = PasswordHasher.ComputeHash("123", PasswordHasher.Supported_HA.SHA512, null), Email = "*****@*****.**", Role = Role.Employee }; User employee3 = new User() { Username = "******", PasswordHash = PasswordHasher.ComputeHash("123", PasswordHasher.Supported_HA.SHA512, null), Email = "*****@*****.**", Role = Role.Employee }; context.Users.AddOrUpdate(u => u.Username, employee1, employee2, employee3); context.SaveChanges(); }
public Seat GetSeat(int auditoriumId, byte number) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Seats.FirstOrDefault(s => s.AuditoriumId == auditoriumId && s.Number == number)); } }
public static bool IsActorExisting(string actorName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Actors.Any(a => a.Name == actorName)); } }
public bool IsSeatExisting(int number, int auditoriumId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Seats.Any(s => s.Number == number && s.AuditoriumId == auditoriumId)); } }
public int GetTownId(string townName) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Towns.First(t => t.Name == townName).Id); } }
public bool IsEmailTaken(string email) { using (var db = new SoftCinemaContext()) { return(db.Users.Any(u => u.Email == email)); } }
public bool IsMovieExisting(string movieName, int releaseYear) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Movies.Any(m => m.Name == movieName && m.ReleaseYear == releaseYear)); } }
public bool IsUserDeleted(string username) { using (var db = new SoftCinemaContext()) { return(db.Users.FirstOrDefault(u => u.Username == username).IsDeleted); } }
public int GetAuditoriumId(byte auditoriumNumber, int cinemaId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Auditoriums.First(a => a.CinemaId == cinemaId && a.Number == auditoriumNumber).Id); } }
public User GetUser(string username) { using (var db = new SoftCinemaContext()) { return(db.Users.Include(u => u.ProfilePicture).FirstOrDefault(u => u.Username == username)); } }
public bool IsAuditoriumExisting(byte number, int cinemaId) { using (SoftCinemaContext context = new SoftCinemaContext()) { return(context.Auditoriums.Any(a => a.CinemaId == cinemaId && a.Number == number)); } }
public static string[] GetHoursForMoviesByDateMovieNameAndYear(string town, string cinema, string movie, int movieYear, string date) { using (SoftCinemaContext context = new SoftCinemaContext()) { var d = date.Split().ToArray(); var day = d[0]; var month = DateTime.ParseExact(d[1], "MMM", CultureInfo.CurrentCulture).Month.ToString(); var list = new List <string>(); var dates = context.Screenings.Where( s => s.Movie.Name == movie && s.Auditorium.Cinema.Town.Name == town && s.Auditorium.Cinema.Name == cinema && s.Start.Day.ToString() == day && s.Start.Month.ToString() == month && s.Movie.ReleaseYear == movieYear).Select(s => s.Start).OrderBy(s => s.Hour).ToArray(); foreach (var dateTime in dates) { var hour = dateTime.ToString("hh"); var minutes = dateTime.ToString("mm"); var part = dateTime.ToString("tt", CultureInfo.InvariantCulture); list.Add($"{hour}:{minutes} {part}"); } return(list.Distinct().ToArray()); } }