示例#1
0
 private void CountThumbs(TblMovie movie, bool up)
 {
     if (up)
     {
         if (movie.Likes == null)
         {
             movie.Likes = 1;
         }
         else
         {
             movie.Likes++;
         }
     }
     else
     {
         if (movie.Dislikes == null)
         {
             movie.Dislikes = 1;
         }
         else
         {
             movie.Dislikes++;
         }
     }
 }
示例#2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("MovieId,MovieName,Director,Year,Synopsis,PosterLink,TrailerLink,Likes,Dislikes")] TblMovie tblMovie)
        {
            if (id != tblMovie.MovieId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _movieRepository.Update(tblMovie);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TblMovieExists(tblMovie.MovieId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tblMovie));
        }
示例#3
0
        public async Task TestAddMovie()
        {
            var movie = new TblMovie();

            movie.MovieId = Guid.NewGuid();
            Assert.True(await repo.Add(movie));
        }
示例#4
0
        public IActionResult Delete(int mid)
        {
            TblMovie movie = entity.TblMovie.Where(e => e.Mid == mid).FirstOrDefault();

            entity.TblMovie.Remove(movie);
            entity.SaveChanges();
            return(Ok(new { Message = "Deleted Successfully" }));
        }
示例#5
0
 private static void InsertData(TblMovie t)
 {
     using (var db = new pubsContext())
     {
         db.TblMovies.Add(t);
         db.SaveChanges();
     }
 }
示例#6
0
        public async Task <TblMovie> AddMovie(TblMovie tblMovie)
        {
            await _context.TblMovie.AddAsync(tblMovie);

            await _context.SaveChangesAsync();

            return(tblMovie);
        }
示例#7
0
        public ActionResult MovieUpdatee(TblMovie t)
        {
            var movie = db.TblMovie.Find(t.MovieId);

            movie.Name      = t.Name;
            movie.Director  = t.Director;
            movie.MovieYear = t.MovieYear;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#8
0
 private static void NewMethod()
 {
     using (var db = new pubsContext())
     {
         TblMovie t = AcceptData();
         Console.WriteLine("Please enter the movie details");
         InsertData(t);
         DisplayData();
     }
 }
示例#9
0
        public bool DoesExist(Guid id)
        {
            TblMovie movie = _context.TblMovie.FirstOrDefault(x => x.MovieId == id);

            if (movie != null)
            {
                return(true);
            }
            return(false);
        }
示例#10
0
        public async Task <IActionResult> Create([Bind("MovieId,MovieName,Director,Year,Synopsis,PosterLink,TrailerLink,Likes,Dislikes")] TblMovie tblMovie)
        {
            if (ModelState.IsValid)
            {
                tblMovie.MovieId = Guid.NewGuid();
                await _movieRepository.Add(tblMovie);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tblMovie));
        }
示例#11
0
        public IActionResult Put([FromBody] TblMovie moviedet, int mid)
        {
            TblMovie movie = entity.TblMovie.Where(e => e.Mid == mid).FirstOrDefault();

            movie.Mname    = moviedet.Mname;
            movie.Mtype    = moviedet.Mtype;
            movie.Mdate    = moviedet.Mdate;
            movie.Mbooking = moviedet.Mbooking;
            entity.SaveChanges();
            return(Ok(new { Message = "Updated Successfully" }));
        }
示例#12
0
        public IActionResult Post([FromBody] TblMovie moviedet)
        {
            TblMovie movie = new TblMovie();

            movie.Mid      = moviedet.Mid;
            movie.Mname    = moviedet.Mname;
            movie.Mtype    = moviedet.Mtype;
            movie.Mdate    = moviedet.Mdate;
            movie.Mbooking = moviedet.Mbooking;
            entity.TblMovie.Add(movie);
            entity.SaveChanges();
            return(Ok(new { Message = "New Movie Added Successfully" }));
        }
        public TblMovie movieByNameExists(TblMovie tMovie)
        {
            var movies = getMovieFromList();

            foreach (TblMovie tblMovie in movies)
            {
                if (tblMovie.ATitle == tMovie.ATitle)
                {
                    return(null);
                }
            }
            return(tMovie);
        }
        public async Task GivenAValidMovie_WhenIPostANewMovie_ThenItReturnsOkWithResponse()
        {
            _mockMovieRepository = new Mock <IMovieRepository>();
            _mockMovieMapper     = new Mock <IMapper>();
            TblMovie expectedMovie = new TblMovie
            {
                AMovieId          = 55,
                ATitle            = "redemption",
                AMovieDescription = "An action comedy adventure about brilliant robotics prodigy Hiro Hamada, who finds himself in the grips of a criminal plot that threatens to destroy the fast-paced, high-tech city of San Fransokyo. With the help of his closest companion-a robot named Baymax-Hiro joins forces with a reluctant team of first-time crime fighters on a mission to save their city.",
                ADuration         = "105 min",
                APrice            = "10",
                APurchasePrice    = "25",
                ARating           = 5,
                AImageLink        = "http://upload.wikimedia.org/wikipedia/en/4/4b/Big_Hero_6_%28film%29_poster.jpg",
                ATrailerLink      = "//www.youtube.com/embed/z3biFxZIJOQ",
                AGenre            = "Comedy",
                AWideImage        = "https://github.com/tushar23091998/MovieRentalApp-FrontEnd/blob/master/src/app/images/bighero6.jpg?raw=true"
            };

            _mockMovieMapper.Setup(mapper => mapper.Map <TblMovie>(It.IsAny <MovieForDetailedDto>()))
            .Returns(expectedMovie);
            _mockMovieRepository.Setup(repo => repo.AddMovie(It.IsAny <TblMovie>()))
            .ReturnsAsync((TblMovie movie) => movie);

            _moviesController = new MoviesController(_mockMovieRepository.Object, _mockMovieMapper.Object);
            var tblMovie = await _moviesController.AddMovie(new MovieForDetailedDto
            {
                AMovieId          = 55,
                ATitle            = "redemption",
                AMovieDescription = "An action comedy adventure about brilliant robotics prodigy Hiro Hamada, who finds himself in the grips of a criminal plot that threatens to destroy the fast-paced, high-tech city of San Fransokyo. With the help of his closest companion-a robot named Baymax-Hiro joins forces with a reluctant team of first-time crime fighters on a mission to save their city.",
                ADuration         = "105 min",
                APrice            = "10",
                APurchasePrice    = "25",
                ARating           = 5,
                AImageLink        = "http://upload.wikimedia.org/wikipedia/en/4/4b/Big_Hero_6_%28film%29_poster.jpg",
                ATrailerLink      = "//www.youtube.com/embed/z3biFxZIJOQ",
                AGenre            = "Comedy",
                AWideImage        = "https://github.com/tushar23091998/MovieRentalApp-FrontEnd/blob/master/src/app/images/bighero6.jpg?raw=true"
            });

            var okResult = tblMovie as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
            Assert.NotNull(okResult);
            Assert.IsAssignableFrom <OkObjectResult>(tblMovie);
            var result = ((OkObjectResult)tblMovie).Value;

            Assert.NotNull(result);
            Assert.AreEqual(expectedMovie, result);
            Assert.IsAssignableFrom <TblMovie>(result);
        }
示例#15
0
        public async Task <bool> Update(TblMovie item)
        {
            _context.TblMovie.Update(item);
            var result = await _context.SaveChangesAsync();

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#16
0
        public async Task <bool> Delete(Guid id)
        {
            TblMovie movie = _context.TblMovie.FirstOrDefault(x => x.MovieId == id);

            _context.TblMovie.Remove(movie);
            var result = await _context.SaveChangesAsync();

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#17
0
        public async Task <IActionResult> AddLikesDislikes(Guid id, bool up)
        {
            TblUser  user  = CurrentUser.Users[HttpContext.Session.GetString("token")];
            TblMovie movie = await _movieRepository.GetSingle(id);

            Guid[] movieUser = new Guid[] { user.UserId, movie.MovieId };
            foreach (var item in CurrentUser.MovieUser)
            {
                if (item[0] == movieUser[0] && item[1] == movieUser[1])
                {
                    TempData["message"] = "Already voted";
                    return(RedirectToAction("Details", new { id = movie.MovieId }));
                }
            }
            CountThumbs(movie, up);
            await _movieRepository.Update(movie);

            CurrentUser.MovieUser.Add(movieUser);
            TempData["message"] = "You successfully voted";
            return(RedirectToAction("Details", new { id = movie.MovieId }));
        }
示例#18
0
 public ActionResult Movieadd(TblMovie t)
 {
     db.TblMovie.Add(t);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public bool AddMovie(TblMovie movie)
 {
     _context.TblMovie.Add(movie);
     return(_context.SaveChanges() > 0);
 }
示例#20
0
        public bool AddMovie(MovieViewModel movie)
        {
            Images image = new Images()
            {
                ImagePath = movie.ImagePath
            };

            _context.Images.Add(image);

            if (_context.SaveChanges() > 0)
            {
                TblMovie tblMovie = new TblMovie()
                {
                    CinemaId          = movie.CinemaId,
                    MovieGenreId      = movie.MovieGenreId,
                    IsBookable        = movie.IsBookable,
                    MovieName         = movie.MovieName,
                    MovieDescription  = movie.MovieDescription,
                    ReleaseDate       = movie.ReleaseDate,
                    MovieLength       = movie.MovieLength,
                    PriceForAdults    = movie.PriceForAdults,
                    PriceForChildrens = movie.PriceForChildrens,
                    //ShowTimeIds = movie.ShowTimeIds,
                    Rating               = movie.Rating,
                    LanguageId           = movie.LanguageId,
                    Image                = image.ImageId,
                    CreatedByUserId      = movie.CreatedByUserId,
                    LastModifiedByUserId = movie.LastModifiedByUserId,
                    CreatedOnDate        = movie.CreatedOnDate,
                    LastModifiedOnDate   = movie.LastModifiedOnDate,
                    IsDeleted            = movie.IsDeleted
                };

                var cinemaAdded = _movieRepository.AddMovie(tblMovie);

                if (cinemaAdded)
                {
                    TblShowTime showTime = new TblShowTime()
                    {
                        CinemaId             = movie.CinemaId,
                        MovieId              = tblMovie.MovieId,
                        Time                 = movie.ShowTime,
                        CreatedByUserId      = movie.CreatedByUserId,
                        LastModifiedByUserId = movie.LastModifiedByUserId,
                        CreatedOnDate        = DateTime.Now.ToShortDateString(),
                        LastModifiedOnDate   = DateTime.Now.ToShortDateString(),
                    };

                    _context.TblShowTime.Add(showTime);

                    if (_context.SaveChanges() > 0)
                    {
                        var myMovie = _context.TblMovie.Where(r => r.MovieId == tblMovie.MovieId).SingleOrDefault();
                        myMovie.ShowTimeIds = showTime.ShowTimeId.ToString();
                        _movieRepository.EditMovie(myMovie);
                    }
                    return(true);
                }
            }

            return(false);
        }
示例#21
0
 public void Delete(TblMovie tblMovie)
 {
     _context.TblMovie.Remove(tblMovie);
     _context.SaveChangesAsync();
 }
 public bool EditMovie(TblMovie movie)
 {
     _context.TblMovie.Update(movie);
     _context.Entry(movie).State = EntityState.Modified;
     return(_context.SaveChanges() > 0);
 }