public async Task <ActionResult <Screening> > AddScreening([FromForm] Screening screening) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var movie = context.Movies.FirstOrDefault(m => m.MovieId == screening.MovieId); if (movie == null) { return(NotFound()); } screening.Movie = movie; var screeningRoom = context.ScreeningRooms.FirstOrDefault(sr => sr.ScreeningRoomId == screening.ScreeningRoomId); if (screeningRoom == null) { return(NotFound()); } screening.ScreeningRoom = screeningRoom; context.Add(screening); await context.SaveChangesAsync(); return(new OkObjectResult(screening)); }
public virtual TModel Insert(TInsert request) { var entity = _mapper.Map <TDatabase>(request); _context.Add(entity); _context.SaveChanges(); return(_mapper.Map <TModel>(entity)); }
public async Task <IActionResult> Create([Bind("RoomId,Name")] Room room) { if (ModelState.IsValid) { _context.Add(room); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(room)); }
public async Task <IActionResult> Create([Bind("PredstavaID,Predstava_cas,FilmID,DvoranaID")] Predstava predstava) { if (ModelState.IsValid) { _context.Add(predstava); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(predstava)); }
public async Task <IActionResult> Create([Bind("PeopleID,Name")] People people) { if (ModelState.IsValid) { _context.Add(people); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(people)); }
//[ValidateAntiForgeryToken] public async Task <IActionResult> Create([Bind("FilmID,Film_ime,Film_trajanje,Film_reziser,Film_opis,Film_img")] Film film) { if (ModelState.IsValid) { _context.Add(film); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(film)); }
public async Task <IActionResult> Create([Bind("SeatID,Row,Number")] Seat seat) { if (ModelState.IsValid) { _context.Add(seat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(seat)); }
public async Task <IActionResult> Create([Bind("MovieID,Title,Rating,Length,StartDate,EndDate,CoverImage")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public List <Model.Sjedista> Insert(SjedistaInsertRequest request) { var entity = _mapper.Map <List <Database.Sjedista> >(request.sjedista); foreach (var item in entity) { _context.Add(item); _context.SaveChanges(); } return(_mapper.Map <List <Model.Sjedista> >(request.sjedista)); }
public async Task <IActionResult> Create([Bind("ReservationId,ShowingID,Seats,Price")] Reservation reservation) { if (ModelState.IsValid) { _context.Add(reservation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ShowingID"] = new SelectList(_context.showings, "ShowingID", "ShowingID", reservation.ShowingID); return(View(reservation)); }
public async Task <IActionResult> Create([Bind("DirectorsID,MovieID,PeopleID")] Directors directors) { if (ModelState.IsValid) { _context.Add(directors); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MovieID"] = new SelectList(_context.movies, "MovieID", "Title", directors.MovieID); ViewData["PeopleID"] = new SelectList(_context.people, "PeopleID", "Name", directors.PeopleID); return(View(directors)); }
public async Task <IActionResult> Create([Bind("GenreMovieID,MovieID,GenreID")] GenreMovie genreMovie) { if (ModelState.IsValid) { _context.Add(genreMovie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GenreID"] = new SelectList(_context.genres, "GenreID", "GenreName", genreMovie.GenreID); ViewData["MovieID"] = new SelectList(_context.movies, "MovieID", "Title", genreMovie.MovieID); return(View(genreMovie)); }
public async Task <IActionResult> Create([Bind("ShowingID,MovieID,RoomID,StartTime")] Showing showing) { if (ModelState.IsValid) { _context.Add(showing); await _context.SaveChangesAsync(); /* Dodaj še vse sedeže */ return(RedirectToAction(nameof(Index))); } ViewData["MovieID"] = new SelectList(_context.movies, "MovieID", "Title", showing.MovieID); ViewData["RoomID"] = new SelectList(_context.rooms, "RoomId", "Name", showing.RoomID); return(View(showing)); }
public async Task <ActionResult <Movie> > AddMovie([FromForm] Movie movie) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (context.Movies.FirstOrDefault(m => m.Title == movie.Title) != null) { return(Conflict()); } context.Add(movie); await context.SaveChangesAsync(); return(new OkObjectResult(movie)); }
public async Task <ActionResult <ScreeningRoom> > AddScreeningRoom([FromForm] ScreeningRoom room) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (context.ScreeningRooms.FirstOrDefault(sm => sm.Name == room.Name) != null) { return(Conflict()); } context.Add(room); await context.SaveChangesAsync(); return(new OkObjectResult(room)); }
public Ulaznice Insert(UlazniceInsertRequest request, string baseUrl) { var entity = _mapper.Map <Database.Ulaznice>(request); _context.Add(entity); _context.SaveChanges(); QRCodeGenerator qr = new QRCodeGenerator(); QRCodeData data = qr.CreateQrCode(baseUrl + "api/Ulaznice/Provjera/" + entity.UlaznicaID, QRCodeGenerator.ECCLevel.Q); QRCode code = new QRCode(data); Bitmap qrCodeImage = code.GetGraphic(10); var bitmapBytes = BitmapToBytes(qrCodeImage); entity.BarCodeIMG = bitmapBytes; _context.SaveChanges(); return(_mapper.Map <Model.Ulaznice>(entity)); }
public void Add(Seanse seanse) { _context.Add(seanse); _context.SaveChangesAsync(); }