public Subtitles Create(Subtitles subtitles) { var subs = _context.Subtitles.Add(subtitles); _context.SaveChanges(); return(subs); }
public Movie Create(Movie movie) { var mov = _context.Movies.Add(movie); _context.SaveChanges(); return(mov); }
public Series Create(Series series) { var sers = _context.Series.Add(series); _context.SaveChanges(); return(sers); }
public Genre Create(Genre genre) { var gen = _context.Genres.Add(genre); _context.SaveChanges(); return(gen); }
public Director Create(Director director) { var dir = _context.Directors.Add(director); _context.SaveChanges(); return(dir); }
public Writer Create(Writer writer) { var wr = _context.Writers.Add(writer); _context.SaveChanges(); return(wr); }
public Season Create(Season season) { var seas = _context.Seasons.Add(season); _context.SaveChanges(); return(seas); }
public async Task <IActionResult> EditWithKlantId(int id, int[] reserveringId) { if (ModelState.IsValid) { var reserveringenklant = await _context.Reserveringen.Where(r => r.KlantId == id).ToListAsync(); foreach (var item in reserveringenklant) { item.Bezet = false; item.KlantId = null; _context.Update(item); _context.SaveChanges(); } foreach (var item in reserveringId) { var reservering = await _context.Reserveringen.FindAsync(item); reservering.Bezet = true; reservering.KlantId = id; _context.Update(reservering); _context.SaveChanges(); } } return(RedirectToAction(nameof(Index), "Klanten")); }
public ContentPath Create(ContentPath contentPath) { var path = _context.ContentPaths.Add(contentPath); _context.SaveChanges(); return(path); }
public Actor Create(Actor actor) { var ac = _context.Actors.Add(actor); _context.SaveChanges(); return(ac); }
public Episode Create(Episode episode) { var ep = _context.Episodes.Add(episode); _context.SaveChanges(); return(ep); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Type")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "Id,Name,Duration")] Movie movie) { if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movie)); }
public ActionResult Create([Bind(Include = "Id,Date,MovieID,HallID")] Projection projection) { if (ModelState.IsValid) { db.Projections.Add(projection); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.HallID = new SelectList(db.Halls, "Id", "Name", projection.HallID); ViewBag.MovieID = new SelectList(db.Movies, "Id", "Name", projection.MovieID); return(View(projection)); }
public ActionResult Create([Bind(Include = "Id,HasAttended,ProjectionId,UserId")] Reservation reservation) { if (ModelState.IsValid) { db.Reservations.Add(reservation); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProjectionId = new SelectList(db.Projections, "Id", "Id", reservation.ProjectionId); ViewBag.UserId = new SelectList(db.Users, "Id", "FirstName", reservation.UserId); return(View(reservation)); }
/// <summary> /// Update the search /// </summary> /// <returns>True if there are searches that were updated</returns> public Boolean updateSearch() { TheaterContext context = new TheaterContext(); var searches = from s in context.Searches where s.SearchID == this.SearchID select s; foreach (Search sr in searches) { sr.Date = DateTime.Now; } context.SaveChanges(); return(context.SaveChanges() > 0); }
public void ReserveShow(MovieReservation reservation) { if (reservation == null) { throw new ArgumentNullException(nameof(reservation), $"{nameof(reservation)} is null."); } if (reservation.Seats.Count() == 0) { throw new ArgumentException("At least one seat must be selected to book a reservation."); } using (var context = new TheaterContext()) { foreach (var seat in reservation.Seats) { var existing = context.Reservations.SingleOrDefault(x => x.ShowingId == reservation.ShowingId && x.TheaterId == reservation.TheaterId && x.Row == seat.Row && x.SeatNumber == seat.Number); if (existing != null) { throw new Exception($"Seat {seat.Row}-{seat.Number} has already been reserved."); } context.Reservations.Add(new Entities.Reservation { ShowingId = reservation.ShowingId, TheaterId = reservation.TheaterId, Row = seat.Row, SeatNumber = seat.Number }); } context.SaveChanges(); } }
public bool DeleteUser(AppUser user) { User us = null; using (var dbContext = new TheaterContext()) { foreach (User u in dbContext.Users) { if (u.Username == user.Username) { us = u; break; } } if (us == null) { return(false); } else { dbContext.Users.Remove(us); dbContext.SaveChanges(); return(true); } } }
public bool DeleteTicket(AppTicket ticket) { Ticket t = new Ticket(ticket); bool found = false; using (var dbContext = new TheaterContext()) { foreach (Ticket item in dbContext.Tickets) { if (item.Id == t.Id && item.Price == t.Price && item.Tag == t.Tag) { t = item; found = true; } } if (found) { dbContext.Tickets.Remove(t); dbContext.SaveChanges(); return(true); } else { return(false); } } }
/// <summary> /// Add Search /// </summary> /// <param name="searchToAdd"></param> public void addSearch(Search searchToAdd) { TheaterContext context = new TheaterContext(); context.Searches.Add(searchToAdd); context.SaveChanges(); }
public int AddTicket(AppTicket ticket) { Ticket t = new Ticket(ticket); int oldId = t.Id; using (var dbContext = new TheaterContext()) { foreach (Ticket item in dbContext.Tickets) { if (item.Id == t.Id) { return(-1); } } dbContext.Tickets.Add(t); dbContext.SaveChanges(); } using (var dbContext = new TheaterContext()) { foreach (TicketItem item in dbContext.TicketItems) { if (item.TicketId == oldId) { item.TicketId = t.Id; } } dbContext.SaveChanges(); return(dbContext.Tickets.ToList().Last().Id); } }
public static bool addNewMovieToUser(Movie movieToAdd, String strUserName) { TheaterContext context = new TheaterContext(); try { bool b = false; // Check if the movie exist if (!context.Movies.Any(other => other.IMDBID == movieToAdd.IMDBID)) { b = movieToAdd.addNewMovie(); } // Check if the movie is already on the user's list if (!isTheMovieOnMyList(movieToAdd.IMDBID, strUserName)) { // Add the movie to the user context.UserMovies.Add(new UserMovie { UserID = strUserName, MovieID = movieToAdd.IMDBID }); context.SaveChanges(); b = true; } return(b); } catch (Exception e) { return(false); } }
public void AddTheater(Theater theater) { using (var context = new TheaterContext()) { context.Theaters.Add(theater); context.SaveChanges(); } }
public void AddAuditorium(Auditorium auditorium) { using (var context = new TheaterContext()) { context.Auditoriums.Add(auditorium); context.SaveChanges(); } }
public ActionResult Index() { db.Users.Add(new Core.DAL.User() { FirstName = "Filip", LastName = "Selvievski", Type = Core.DAL.UserType.Admin }); db.SaveChanges(); return(View()); }
/// <summary> /// Delete a search /// </summary> /// <param name="nSearchID">Search ID</param> /// <returns>True if there are searches that were deleted</returns> public Boolean deleteSearch(Int32 nSearchID) { TheaterContext context = new TheaterContext(); Search s = context.Searches.SingleOrDefault(c => c.SearchID == nSearchID); context.Searches.Remove(s); return(context.SaveChanges() > 0); }
public void CloneTicket(AppTicket ticket) { Ticket t = new Ticket(ticket); Ticket clonedTicket = (Ticket)t.Clone(); using (var context = new TheaterContext()) { context.Tickets.Add(clonedTicket); context.SaveChanges(); } }
public bool ChangeTicket2(AppTicket ticket) { Ticket t = new Ticket(ticket); int oldId = t.Id; bool found = false; using (var dbContext = new TheaterContext()) { foreach (Ticket item in dbContext.Tickets) { if (item.Id == t.Id) { item.Tag = t.Tag; item.Price = t.Price; found = true; break; } } if (found) { foreach (TicketItem item in dbContext.TicketItems) { if (item.TicketId == t.Id) { item.TotalPrice = t.Price * item.Quantity; } } } else { dbContext.Tickets.Add(t); } dbContext.SaveChanges(); } using (var dbContext = new TheaterContext()) { foreach (TicketItem item in dbContext.TicketItems) { if (item.TicketId == oldId) { item.TicketId = t.Id; } if (item.TicketId == t.Id) { item.TotalPrice = t.Price * item.Quantity; } } dbContext.SaveChanges(); return(true); } }
public Boolean deleteUserMovie(String movieToRemove, String strUserName) { Boolean answer = false; TheaterContext context = new TheaterContext(); UserMovie um = context.UserMovies.SingleOrDefault(s => s.MovieID == movieToRemove && s.UserID == strUserName); if (um != null) { context.UserMovies.Remove(um); answer = context.SaveChanges() > 0; } return(answer); }
/// <summary> /// /// </summary> /// <param name="movieToUpdate"></param> /// <returns></returns> public Boolean updateStars(String strMovieToUpdate, Int32 nStars) { Boolean answer = false; TheaterContext context = new TheaterContext(); Movie specificMovie = context.Movies.SingleOrDefault(m => m.IMDBID == strMovieToUpdate); if (specificMovie != null) { specificMovie.Stars = (specificMovie.Stars * specificMovie.Votes++ + nStars) / specificMovie.Votes; context.SaveChanges(); answer = true; } return(answer); }