Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public virtual TModel Insert(TInsert request)
        {
            var entity = _mapper.Map <TDatabase>(request);

            _context.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <TModel>(entity));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        //[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));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
        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));
        }
Exemplo n.º 13
0
        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));
        }
Exemplo n.º 14
0
        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));
        }
Exemplo n.º 15
0
        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));
        }
Exemplo n.º 16
0
        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));
        }
Exemplo n.º 17
0
 public void Add(Seanse seanse)
 {
     _context.Add(seanse);
     _context.SaveChangesAsync();
 }