示例#1
0
        public ActionResult Create(Models.Genre model)
        {
            if (ModelState.IsValid)
            {
                if (!genreService.ExistsGenre(model.Name))
                {
                    var dbModel = new Domain.Genre();
                    dbModel.InjectFrom(model);
                    genreService.AddGenre(dbModel);
                    TempData["message"] = string.Format("{0} has been saved", model.Name);
                }

                else
                {
                    ModelState.AddModelError("Name", "This genre is already in the database!!");

                    return(View(model));
                }
                //genreRepository.Add(dbModel);

                //transform the object
                //unitOfWork.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
示例#2
0
        public async Task <bool> AddGenreAsync(Models.Genre genre)
        {
            string uri = AppSettings.GenresEndpoint;

            var token = await _loginService.GetOAuthToken();

            return(await _requestService.PostAsync <Models.Genre, bool>(uri, genre, token));
        }
示例#3
0
        // GET: Store/Browse?type=Cognac
        public ActionResult Browse(string genre)
        {
            var genreModel = new Models.Genre {
                Name = genre
            };

            return(View(genreModel));
        }
示例#4
0
 public IActionResult Edit([DataSourceRequest] DataSourceRequest request, Models.Genre genre)
 {
     if (genre != null && ModelState.IsValid)
     {
         _db.Genre.Update(genre);
         _db.SaveChanges();
     }
     return(Json(new[] { genre }.ToDataSourceResult(request, ModelState)));
 }
示例#5
0
 public ActionResult Delete([DataSourceRequest] DataSourceRequest request, Models.Genre genre)
 {
     if (genre != null)
     {
         _db.Remove(genre);
         _db.SaveChanges();
     }
     return(Json(new[] { genre }.ToDataSourceResult(request, ModelState)));
 }
示例#6
0
        public ActionResult Delete(int id, Models.Genre genre)
        {
            var genreDelete = genreRepository.FindById(id);

            genreDelete.InjectFrom(genre);
            genreRepository.Delete(genreDelete);
            TempData["message"] = string.Format("{0} has been saved", genre.Name);
            unitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
示例#7
0
        public int Create(Models.Genre genre)
        {
            Data.Genre newGenre = new Data.Genre {
                Description = genre.Description
            };
            db.Genres.Add(newGenre);

            db.SaveChanges();
            return(newGenre.Id);
        }
示例#8
0
        public Models.Genre Update(Models.Genre genre)
        {
            var existing = db.Genres.SingleOrDefault(x => x.Id == genre.Id);

            if (existing != null)
            {
                existing.Description = genre.Description;
                db.SaveChanges();
            }
            return(null);
        }
        public MultiSelectList GetGenres()
        {
            List <Genre> Genres = db.Genres.ToList();

            Genre SelectNone = new Models.Genre();

            Genres.Add(SelectNone);

            MultiSelectList AllGenres = new MultiSelectList(Genres.OrderBy(m => m.GenreID), "GenreID", "GenreName");

            return(AllGenres);
        }
示例#10
0
        // GET: Genre/Delete/5
        public ActionResult Delete(int id)
        {
            var genre = genreRepository.FindById(id);

            if (genre == null)
            {
                return(HttpNotFound());
            }
            var genreId = new Models.Genre();

            genreId.InjectFrom(genre);
            return(View(genreId));
        }
示例#11
0
        // GET: Genre/Details/5

        /* public ActionResult Details(int id)
         * {
         *   return View();
         * }*/

        // GET: Genre/Create
        public ActionResult Create()
        {
            var model = new Models.Genre();

            //var films = filmRepository.GetAll();
            //var selectFilms = films.Select(f => new SelectListItem()
            //{
            //    Value = f.Id.ToString(),
            //    Text = f.Name
            //}).ToList();
            //ViewBag.Films = selectFilms;
            return(View(model));
        }
示例#12
0
        public Models.Genre GetById(int id)
        {
            var existing = db.Genres.SingleOrDefault(x => x.Id == id);

            if (existing == null)
            {
                return(null);
            }
            Models.Genre g = new Models.Genre {
                Id = existing.Id, Description = existing.Description
            };

            return(g);
        }
示例#13
0
 public Task <Models.Game> GetGameAsync(int gameId)
 {
     Models.Genre genreFPS = new Models.Genre()
     {
         GenreId = 1, Name = "FPS"
     };
     return(Task.FromResult(new Models.Game
     {
         GameId = 1,
         Name = "Rainbow Six Siege",
         Genres = new List <Models.Genre> {
             genreFPS
         },
         IconSource = "https://i.redd.it/iznunq2m8vgy.png",
         ImageSource = "https://www.torcedores.com/content/uploads/2018/02/erwmqs3hzvkfqudfutqdyh_tb7c.jpg"
     }));
 }
示例#14
0
        public ActionResult Edit(Models.Genre genre)
        {
            if (ModelState.IsValid)
            {
                var dbGenre = new Domain.Genre();
                dbGenre.InjectFrom(genre);
                genreRepository.Update(dbGenre);
                TempData["message"] = string.Format("{0} has been saved", genre.Name);
                unitOfWork.Commit();
            }
            else
            {
                return(View(genre));
            }

            return(RedirectToAction("Index"));
        }
示例#15
0
        public MultiSelectList GetAllGenres()
        {
            List <Genre> Genres = db.Genres.ToList();

            //Add a record for all languages
            Genre SelectNone = new Models.Genre()
            {
                GenreID = 0, GenreType = "All Genres"
            };

            Genres.Add(SelectNone);

            //Convert list to select list
            MultiSelectList AllGenres = new MultiSelectList(Genres.OrderBy(m => m.GenreID), "GenreID", "GenreType");

            //Return the select list
            return(AllGenres);
        }
示例#16
0
        public static Movie ToMovie(MoviePostModel movie)
        {
            Models.Genre genre = new Models.Genre();

            if (movie.MovieGenre == "Comedy")
            {
                genre = Genre.Comedy;
            }
            else if (movie.MovieGenre == "Horror")
            {
                genre = Genre.Horror;
            }
            else if (movie.MovieGenre == "Thriller")
            {
                genre = Genre.Thriller;
            }

            Models.Watched watched = new Models.Watched();

            if (movie.WasWatched == "YES")
            {
                watched = Watched.YES;
            }
            else
            {
                watched = Watched.NO;
            }

            return(new Movie
            {
                Title = movie.Title,
                Description = movie.Description,
                MovieGenre = genre,
                DurationInMinutes = movie.DurationInMinutes,
                ReleseYear = movie.ReleseYear,
                Director = movie.Director,
                DateAdded = movie.DateAdded,
                Rating = movie.Rating,
                WasWatched = watched,
                Comments = CommentGetModel.ToComments(movie.Comments)
            });
        }
示例#17
0
        public static Movie ToUpdateMovie(MoviePostModel moviePostModel, Movie movie)
        {
            Models.Genre genre = new Models.Genre();

            if (moviePostModel.MovieGenre == "Comedy")
            {
                genre = Genre.Comedy;
            }
            else if (moviePostModel.MovieGenre == "Horror")
            {
                genre = Genre.Horror;
            }
            else if (moviePostModel.MovieGenre == "Thriller")
            {
                genre = Genre.Thriller;
            }

            Models.Watched watched = new Models.Watched();

            if (moviePostModel.WasWatched == "YES")
            {
                watched = Watched.YES;
            }
            else
            {
                watched = Watched.NO;
            }

            movie.Title             = moviePostModel.Title;
            movie.Description       = moviePostModel.Description;
            movie.MovieGenre        = genre;
            movie.DurationInMinutes = moviePostModel.DurationInMinutes;
            movie.ReleseYear        = moviePostModel.ReleseYear;
            movie.Director          = moviePostModel.Director;
            movie.DateAdded         = moviePostModel.DateAdded;
            movie.Rating            = moviePostModel.Rating;
            movie.WasWatched        = watched;
            movie.Comments          = CommentGetModel.ToComments(moviePostModel.Comments);

            return(movie);
        }
示例#18
0
        public static Movie ToMovie(MoviePostModel movie)
        {
            Models.Genre genre = Models.Genre.action;

            if (movie.Genre == "comedy")
            {
                genre = Models.Genre.comedy;
            }
            else if (movie.Genre == "horror")
            {
                genre = Models.Genre.horror;
            }
            else
            {
                genre = Models.Genre.thriller;
            }

            Models.Watched watched = Models.Watched.yes;

            if (movie.Watched == "no")
            {
                watched = Models.Watched.no;
            }

            return(new Movie
            {
                Title = movie.Title,
                Description = movie.Description,
                Genre = genre,
                DurationInMinutes = movie.DurationInMinutes,
                YearOfRelease = movie.YearOfRelease,
                Director = movie.Director,
                Rating = movie.Rating,
                Watched = watched,
                DateAdded = movie.DateAdded,
                Comments = movie.Comments
            });
        }
示例#19
0
        public async Task <CommandResult> ExecuteAsync(CashbackCommandsHandler handler)
        {
            var obj = await handler.DbContext.Genres.Where(w => w.Id == Id).FirstOrDefaultAsync();

            if (obj != null)
            {
                return(await Task.FromResult(new CommandResult(0, ErrorCode.DuplicateUniqueIdentifier)));
            }

            obj = new Models.Genre(Id, Name);
            foreach (var item in Cashback)
            {
                obj.AddCashbackConfig(new Models.Cashback(item.Id, obj.Id, item.DayOfWeek, item.Percent));
            }

            await handler.DbContext.Genres.AddAsync(obj);

            await handler.DbContext.Cashbacks.AddRangeAsync(obj.Cashbacks);

            var rows = await handler.DbContext.SaveChangesAsync();

            return(await Task.FromResult(new CommandResult(rows, ErrorCode.None)));
        }
示例#20
0
        //Retrieve Full Movie Info and DVDs based on MovieID from the SQL DB
        public List<DVD> RetrieveFullDVDInfoFromDB(int movieId)
        {
            List<DVD> listOfDVDInfo = new List<DVD>();

            using (var cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd = new SqlCommand();

                Models.Movie movieInfo = new Models.Movie();

                //Get Movie Info including Director & Studio By MovieId

                cmd.CommandText = "GetMovieInfoByMovieId";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        movieInfo.MovieId = int.Parse(dr["MovieID"].ToString());
                        movieInfo.MovieTitle = dr["MovieTitle"].ToString();
                        movieInfo.MovieTMDBNum = int.Parse(dr["MovieTMDBNum"].ToString());
                        movieInfo.ReleaseDate = DateTime.Parse(dr["ReleaseDate"].ToString());
                        movieInfo.MpaaRating = dr["Rating"].ToString();
                        movieInfo.Duration = int.Parse(dr["DurationInMin"].ToString());
                        if (dr["Synopsis"] != DBNull.Value)
                        {
                            movieInfo.Synopsis = dr["Synopsis"].ToString();
                        }
                        if (dr["PosterUrl"] != DBNull.Value)
                        {
                            movieInfo.PosterUrl = dr["PosterUrl"].ToString();
                        }
                        if (dr["YouTubeTrailer"] != DBNull.Value)
                        {
                            movieInfo.YouTubeTrailer = dr["YouTubeTrailer"].ToString();
                        }
                        movieInfo.Director.DirectorId = int.Parse(dr["DirectorID"].ToString());
                        movieInfo.Director.DirectorName = dr["DirectorName"].ToString();
                        if (dr["DirectorTMDBNum"] != DBNull.Value)
                        {
                            movieInfo.Director.DirectorTMDBNum = int.Parse(dr["DirectorTMDBNum"].ToString());
                        }
                        movieInfo.Studio.StudioId = int.Parse(dr["StudioID"].ToString());
                        movieInfo.Studio.StudioName = dr["StudioName"].ToString();
                        if (dr["StudioTMDBNum"] != DBNull.Value)
                        {
                            movieInfo.Studio.StudioTMDBNum = int.Parse(dr["StudioTMDBNum"].ToString());
                        }

                    }
                }
                cn.Close();

                //Get Actors List for Movie by MovieID
                cmd.CommandText = "GetActorsListByMovieID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        if (dr["ActorID"] != DBNull.Value)
                        {
                            Actor newActor = new Actor();
                            newActor.ActorId = int.Parse(dr["ActorID"].ToString());

                            if (dr["ActorName"] != DBNull.Value)
                            {
                                newActor.ActorName = dr["ActorName"].ToString();
                            }
                            if (dr["ActorTMDBNum"] != DBNull.Value)
                            {
                                newActor.ActorTMDBNum = int.Parse(dr["ActorTMDBNum"].ToString());
                            }
                            if (dr["CharacterName"] != DBNull.Value)
                            {
                                newActor.CharacterName = dr["CharacterName"].ToString();
                            }
                            movieInfo.MovieActors.Add(newActor);
                        }
                    }
                }
                cn.Close();

                //Get Genres List for Movie by MovieID
                cmd.CommandText = "GetGenresListByMovieID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {

                        if (dr["GenreID"] != DBNull.Value)
                        {
                            Models.Genre newGenre = new Models.Genre();
                            newGenre.GenreId = int.Parse(dr["GenreID"].ToString());

                            if (dr["GenreName"] != DBNull.Value)
                            {
                                newGenre.GenreName = dr["GenreName"].ToString();
                            }
                            movieInfo.Genres.Add(newGenre);
                        }
                    }
                }
                cn.Close();

                //Get Movie Aliases List for Movie by MovieID
                cmd.CommandText = "GetMovieAliasesByMovieID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {

                        if (dr["MovieAliasID"] != DBNull.Value)
                        {
                            MovieAlias newMovieAlias = new MovieAlias();
                            newMovieAlias.MovieAliasId = int.Parse(dr["MovieAliasID"].ToString());

                            if (dr["MovieAlias"] != DBNull.Value)
                            {
                                newMovieAlias.MovieAliasTitle = dr["MovieAlias"].ToString();
                            }
                            movieInfo.MovieAliases.Add(newMovieAlias);
                        }
                    }
                }
                cn.Close();

                //Get User Ratings for Movie by MovieID
                cmd.CommandText = "GetUserRatingsByMovieID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {

                        if (dr["UserRatingID"] != DBNull.Value)
                        {
                            UserRating newUserRating = new UserRating();
                            newUserRating.UserRatingId = int.Parse(dr["UserRatingID"].ToString());

                            if (dr["MovieID"] != DBNull.Value)
                            {
                                newUserRating.MovieId = int.Parse(dr["MovieID"].ToString());
                            }
                            if (dr["BorrowerID"] != DBNull.Value)
                            {
                                newUserRating.BorrowerId = int.Parse(dr["BorrowerID"].ToString());
                            }
                            if (dr["Rating"] != DBNull.Value)
                            {
                                newUserRating.Rating = int.Parse(dr["Rating"].ToString());
                            }
                            if (dr["OwnerRating"] != DBNull.Value)
                            {
                                newUserRating.Owner = bool.Parse(dr["OwnerRating"].ToString());
                            }
                            if (dr["FirstName"] != DBNull.Value)
                            {
                                newUserRating.BorrowerName = (dr["FirstName"].ToString() + " " +
                                                              dr["LastName"].ToString());
                            }
                            movieInfo.UserRatings.Add(newUserRating);
                        }
                    }
                }
                cn.Close();

                //Get User Notes for Movie by MovieID
                cmd.CommandText = "GetUserNotesByMovieID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {

                        if (dr["UserNoteID"] != DBNull.Value)
                        {
                            UserNote newUserNote = new UserNote();
                            newUserNote.UserNoteId = int.Parse(dr["UserNoteID"].ToString());

                            if (dr["MovieID"] != DBNull.Value)
                            {
                                newUserNote.MovieId = int.Parse(dr["MovieID"].ToString());
                            }
                            if (dr["MovieTitle"] != DBNull.Value)
                            {
                                newUserNote.MovieTitle = dr["MovieTitle"].ToString();
                            }
                            if (dr["BorrowerID"] != DBNull.Value)
                            {
                                newUserNote.BorrowerId = int.Parse(dr["BorrowerID"].ToString());
                            }
                            if (dr["Note"] != DBNull.Value)
                            {
                                newUserNote.Note = dr["Note"].ToString();
                            }
                            if (dr["OwnerNote"] != DBNull.Value)
                            {
                                newUserNote.Owner = bool.Parse(dr["OwnerNote"].ToString());
                            }
                            if (dr["FirstName"] != DBNull.Value)
                            {
                                newUserNote.BorrowerName = (dr["FirstName"].ToString() + " " + dr["LastName"].ToString());
                            }
                            movieInfo.UserNotes.Add(newUserNote);
                        }
                    }
                }
                cn.Close();

                //Get DVDID and DVDType Info by MovieID
                cmd.CommandText = "GetDVDInfoByMovieID";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Connection = cn;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@MovieID", movieId);

                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        if (dr["DVDID"] != DBNull.Value)
                        {
                            DVD newDVD = new DVD();
                            newDVD.DVDId = int.Parse(dr["DVDID"].ToString());
                            if (dr["DVDType"] != DBNull.Value)
                            {
                                newDVD.DVDType = dr["DVDType"].ToString();
                            }
                            newDVD.Movie = movieInfo;

                            listOfDVDInfo.Add(newDVD);
                        }
                    }
                }
                cn.Close();

                //Get Borrower Statuses for a DVD by DVDID
                foreach (var d in listOfDVDInfo)
                {
                    cmd.CommandText = "GetBorrowerStatusesByDVDID";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Connection = cn;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@DVDID", d.DVDId);

                    cn.Open();
                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (dr["BorrowerStatusID"] != DBNull.Value)
                            {
                                Status newStatus = new Status();
                                newStatus.StatusId = int.Parse(dr["BorrowerStatusID"].ToString());
                                if (dr["BorrowerID"] != DBNull.Value)
                                {
                                    newStatus.Borrower.BorrowerId = int.Parse(dr["BorrowerID"].ToString());
                                }
                                if (dr["DVDID"] != DBNull.Value)
                                {
                                    newStatus.DVDId = int.Parse(dr["DVDID"].ToString());
                                }
                                if (dr["DateBorrowed"] != DBNull.Value)
                                {
                                    newStatus.DateBorrowed = DateTime.Parse(dr["DateBorrowed"].ToString());
                                }
                                if (dr["DateReturned"] != DBNull.Value)
                                {
                                    newStatus.DateReturned = DateTime.Parse(dr["DateReturned"].ToString());
                                }
                                if (dr["IsOwner"] != DBNull.Value)
                                {
                                    newStatus.Borrower.IsOwner = bool.Parse(dr["IsOwner"].ToString());
                                }
                                if (dr["FirstName"] != DBNull.Value)
                                {
                                    newStatus.Borrower.FirstName = dr["FirstName"].ToString();
                                }
                                if (dr["LastName"] != DBNull.Value)
                                {
                                    newStatus.Borrower.LastName = dr["LastName"].ToString();
                                }
                                if (dr["Email"] != DBNull.Value)
                                {
                                    newStatus.Borrower.Email = dr["Email"].ToString();
                                }
                                if (dr["StreetAddress"] != DBNull.Value)
                                {
                                    newStatus.Borrower.Address = dr["StreetAddress"].ToString();
                                }
                                if (dr["City"] != DBNull.Value)
                                {
                                    newStatus.Borrower.City = dr["City"].ToString();
                                }
                                if (dr["State"] != DBNull.Value)
                                {
                                    newStatus.Borrower.State = dr["State"].ToString();
                                }
                                if (dr["Zipcode"] != DBNull.Value)
                                {
                                    newStatus.Borrower.Zipcode = dr["Zipcode"].ToString();
                                }
                                if (dr["Phone"] != DBNull.Value)
                                {
                                    newStatus.Borrower.Phone = dr["Phone"].ToString();
                                }
                                d.Statuses.Add(newStatus);
                            }
                        }
                    }
                    cn.Close();
                }

            }

            return listOfDVDInfo;
        }
示例#21
0
        //Retrieve TMDB info with a TMDBNum
        public Models.Movie ReturnMovieInfoFromTMDB(int tmdbNum)
        {
            TMDbClient client = new TMDbClient("1fee8f2397ff73412985de2bb825f020");

            Movie movie = client.GetMovie(tmdbNum,
                MovieMethods.AlternativeTitles | MovieMethods.Credits | MovieMethods.Images | MovieMethods.Releases |
                MovieMethods.Videos);

            Models.Movie movieInfo = new Models.Movie();
            movieInfo.MovieTitle = movie.Title;
            movieInfo.MovieTMDBNum = movie.Id;
            if (movie.Releases.Countries.FirstOrDefault(m => m.Iso_3166_1 == "US") != null)
            {
                movieInfo.MpaaRating = movie.Releases.Countries.FirstOrDefault(m => m.Iso_3166_1 == "US").Certification;
            }
            else
            {
                movieInfo.MpaaRating = "NR";
            }
            if (movie.ReleaseDate != null)
            {
                movieInfo.ReleaseDate = movie.ReleaseDate.Value.Date;
            }
            if (movie.Overview != null)
            {
                movieInfo.Synopsis = movie.Overview;
            }
            if (movie.Runtime != null)
            {
                movieInfo.Duration = movie.Runtime.Value;
            }
            if (movie.PosterPath != null)
            {
                movieInfo.PosterUrl = "http://image.tmdb.org/t/p/w396" + movie.PosterPath;
            }
            else
            {
                movieInfo.PosterUrl =
                    "http://assets.tmdb.org/assets/7f29bd8b3370c71dd379b0e8b570887c/images/no-poster-w185-v2.png";
            }
            if (movie.Videos.Results.Where(v => v.Type == "Trailer").FirstOrDefault() != null)
            {
                movieInfo.YouTubeTrailer = "http://www.youtube.com/embed/" +
                                           movie.Videos.Results.Where(v => v.Type == "Trailer").FirstOrDefault().Key;
            }
            if (movie.Genres.Count != 0)
            {
                foreach (var g in movie.Genres)
                {
                    var newGenre = new Models.Genre();
                    newGenre.GenreName = g.Name;
                    movieInfo.Genres.Add(newGenre);
                }
            }
            if (movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director") != null)
            {
                movieInfo.Director.DirectorName = movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director").Name;
                movieInfo.Director.DirectorTMDBNum = movie.Credits.Crew.FirstOrDefault(d => d.Job == "Director").Id;
            }
            if (movie.ProductionCompanies.Count != 0)
            {
                movieInfo.Studio.StudioName = movie.ProductionCompanies[0].Name;
                movieInfo.Studio.StudioTMDBNum = movie.ProductionCompanies[0].Id;
            }

            if (movie.AlternativeTitles.Titles.Count != 0)
            {
                foreach (var t in movie.AlternativeTitles.Titles)
                {
                    if (t.Iso_3166_1 == "US")
                    {
                        var newMovieAlias = new MovieAlias();
                        newMovieAlias.MovieAliasTitle = t.Title;
                        movieInfo.MovieAliases.Add(newMovieAlias);
                    }
                }
            }

            if (movie.Credits.Cast.Count < 10 && movie.Credits.Cast.Count > 0)
            {
                foreach (var a in movie.Credits.Cast)
                {
                    Actor newActor = new Actor();
                    newActor.ActorName = a.Name;
                    newActor.ActorTMDBNum = a.Id;
                    newActor.CharacterName = a.Character;
                    movieInfo.MovieActors.Add(newActor);
                }
            }
            else if (movie.Credits.Cast.Count == 0)
            {
                return movieInfo;
            }
            else
            {
                for (int i = 0; i < 10; i++)
                {
                    Actor newActor = new Actor();
                    newActor.ActorName = movie.Credits.Cast[i].Name;
                    newActor.ActorTMDBNum = movie.Credits.Cast[i].Id;
                    newActor.CharacterName = movie.Credits.Cast[i].Character;
                    movieInfo.MovieActors.Add(newActor);
                }
            }

            return movieInfo;
        }
示例#22
0
        //Build ListOfMovies list from SQL Database method (just with basic info)
        public List<Models.Movie> RetrieveMoviesListFromDB()
        {
            List<Models.Movie> moviesListFromDB = new List<Models.Movie>();

            using (var cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd = new SqlCommand();
                cmd.CommandText =
                    ("SELECT [MovieID], [MovieTitle], [ReleaseDate], [Synopsis], [PosterUrl], [Rating] From Movies Where [InCollection]=1");
                cmd.Connection = cn;
                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        Models.Movie movieToAdd = PopulateMovieFromDataReaderShort(dr);
                        moviesListFromDB.Add(movieToAdd);
                    }
                }
            }

            foreach (var movie in moviesListFromDB)
            {
                //Get Genres List for Movie by MovieID
                using (var cn = new SqlConnection(Settings.ConnectionString))
                {
                    var cmd = new SqlCommand();

                    cmd.CommandText = "GetGenresListByMovieID";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Connection = cn;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@MovieID", movie.MovieId);

                    cn.Open();
                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {

                            if (dr["GenreID"] != DBNull.Value)
                            {
                                Models.Genre newGenre = new Models.Genre();
                                newGenre.GenreId = int.Parse(dr["GenreID"].ToString());

                                if (dr["GenreName"] != DBNull.Value)
                                {
                                    newGenre.GenreName = dr["GenreName"].ToString();
                                }
                                movie.Genres.Add(newGenre);
                            }
                        }
                    }
                    cn.Close();
                }
            }
            return moviesListFromDB;
        }
示例#23
0
        private IEnumerable <Models.Game> GetFakeGames()
        {
            Models.Genre genreFPS = new Models.Genre()
            {
                GenreId = 1, Name = "FPS"
            };
            Models.Genre genreAction = new Models.Genre()
            {
                GenreId = 1, Name = "Action"
            };
            Models.Genre genreSurvival = new Models.Genre()
            {
                GenreId = 5, Name = "Survival"
            };
            Models.Genre genreSurvivalHorror = new Models.Genre {
                GenreId = 6, Name = "Survival Horror"
            };
            yield return(new Models.Game
            {
                GameId = 1,
                Name = "Rainbow Six Siege",
                Genres = new List <Models.Genre> {
                    genreFPS
                },
                IconSource = "https://i.redd.it/iznunq2m8vgy.png",
                ImageSource = "https://www.torcedores.com/content/uploads/2018/02/erwmqs3hzvkfqudfutqdyh_tb7c.jpg"
            });

            yield return(new Models.Game
            {
                GameId = 2,
                Name = "Overwatch",
                Genres = new List <Models.Genre> {
                    genreFPS
                },
                IconSource = "https://i.imgur.com/0RIw2RB.png",
                ImageSource = "http://www.base2.com.br/wp-content/uploads/2017/04/overwatch1280jpg-6daa73_1280w.jpg"
            });

            yield return(new Models.Game
            {
                GameId = 3,
                Name = "Destiny 2",
                Genres = new List <Models.Genre> {
                    genreFPS
                },
                IconSource = "http://i44.servimg.com/u/f44/13/94/19/07/destin10.png",
                ImageSource = "https://www.pcguia.pt/wp-content/uploads/2018/02/Destiny-2-900x445.jpg"
            });

            yield return(new Models.Game
            {
                GameId = 4,
                Name = "Playerunkow's Battlegrounds",
                Genres = new List <Models.Genre> {
                    genreSurvival, genreFPS
                },
                IconSource = "https://orig06.deviantart.net/31c8/f/2017/087/1/5/playerunknown_s_battlegrounds_icon_by_troublem4ker-db3tnhy.png",
                ImageSource = "https://www.windowscentral.com/sites/wpcentral.com/files/styles/xlarge/public/field/image/2017/12/pubg-press-2.jpg?itok=hEREwXIC"
            });

            yield return(new Models.Game
            {
                GameId = 6,
                Name = "Dead by Daylight",
                Genres = new List <Models.Genre> {
                    genreSurvivalHorror
                },
                IconSource = "https://www.deadbydaylight.com/manual/img/journal/dbd-journal-hook.png",
                ImageSource = "http://maroonersrock.com/wp-content/uploads/2017/10/Dead-by-Daylight-Freddy-DLC-810x400.jpg"
            });

            yield return(new Models.Game
            {
                GameId = 5,
                Name = "Fortnite",
                Genres = new List <Models.Genre> {
                    genreSurvival, genreFPS
                },
                IconSource = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQyUWh_P9xq4o3Rja1PZsHA7ydEMUZXBJyYuSlxD8UIXBdBjzt_",
                ImageSource = "https://cdn2.unrealengine.com/Fortnite%2Fbattle-royale%2Ffortnite-sniper-1920x1080-f072fcef414cbe680e369a16a8d059d8a01c7636.jpg"
            });
        }
示例#24
0
        public IActionResult Create(Album album, string artistName, string genreName)
        {
            ViewBag.Genre   = new SelectList(_context.Genres, "GenreID", "Name");
            ViewBag.Artists = new SelectList(_context.Artists, "ArtistID", "Name");

            if (artistName != null)
            {
                Artist artist = new Models.Artist();
                artist.Name = artistName;

                var artistCheck = _context.Artists.Any(a => a.Name == artist.Name);
                if (artistCheck == false)
                {
                    _context.Artists.Add(artist);
                    _context.SaveChanges();
                    var art = _context.Artists.Single(a => a.Name == artistName);
                    album.ArtistID = art.ArtistID;
                }
                else
                {
                    var art = _context.Artists.Single(a => a.Name == artistName);
                    album.ArtistID = art.ArtistID;
                }
            }

            if (genreName != null)
            {
                Genre genre = new Models.Genre();
                genre.Name = genreName;

                var genreCheck = _context.Genres.Any(g => g.Name == genre.Name);
                if (genreCheck == false)
                {
                    _context.Genres.Add(genre);
                    _context.SaveChanges();
                    var gen = _context.Genres.Single(g => g.Name == genreName);
                    album.GenreID = gen.GenreID;
                }
                else
                {
                    var gen = _context.Genres.Single(g => g.Name == genreName);
                    album.GenreID = gen.GenreID;
                }
                ModelState.Remove("ArtistID");
                ModelState.Remove("GenreID");
            }
            if (ModelState.IsValid)
            {
                album.AlbumPlaylists = new List <AlbumPlaylist>();
                _context.Albums.Add(album);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            //else
            //{
            //    _context.Albums.Add(album);
            //    _context.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            return(View(album));
        }