public IActionResult Edit(int id, [Bind("MovieSetID,SetName,UserID")] MovieSet movieSet)
        {
            if (id != movieSet.MovieSetID)
            {
                return(NotFound());
            }
            if (!_authmovieset.CheckUserId(id, _httpContextAccessor))
            {
                return(Unauthorized());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _movieset.Update(movieSet);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_authmovieset.MovieSetExists(movieSet.MovieSetID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(movieSet));
        }
Esempio n. 2
0
 protected CutsceneSceneDataProtocol(Cutscene cutscene, MovieSet set)
 {
     this.PlaysForWho           = cutscene.PlaysForWhom;
     this.CutsceneModName       = cutscene.UniqueId.ModName;
     this.CutsceneClassFullName = cutscene.UniqueId.FullClassName;
     this.SceneModName          = cutscene.CurrentScene.UniqueId.ModName;
     this.SceneClassFullName    = cutscene.CurrentScene.UniqueId.FullClassName;
 }
Esempio n. 3
0
        protected CutsceneStartProtocol(Cutscene cutscene, MovieSet set) : base(cutscene, set)
        {
/*LogHelpers.Log( "SEND "
 +"PlaysForWho:"+this.PlaysForWho
 + ", CutsceneModName:" + this.CutsceneModName
 + ", CutsceneClassFullName:" + this.CutsceneClassFullName
 + ", SceneModName:" + this.SceneModName
 + ", SceneClassFullName:" + this.SceneClassFullName );*/
        }
        protected override async Task RefreshInternal()
        {
            MovieSet set = await _metadataService.GetMovieSet(DisplayName);

            SetName     = DisplayNameInternal = set.Name;
            Fanart.Path = set.BackdropPath;
            Poster.Path = set.PosterPath;
            Fanart.RefreshImage();
            Poster.RefreshImage();
        }
 public IActionResult Create([Bind("MovieSetID,SetName,UserID")] MovieSet movieSet)
 {
     if (ModelState.IsValid)
     {
         movieSet.CreationDate = DateTime.Today;
         movieSet.UserID       = _currentuserid.GetCurrentUserId(_httpContextAccessor);
         _movieset.Insert(movieSet);
         return(RedirectToAction("Index"));
     }
     return(View(movieSet));
 }
        public MovieSet CreateMovieSet(string name)
        {
            var movieSet = new MovieSet();

            movieSet.Name = name;

            _context.Add(movieSet);
            Console.WriteLine(String.Format("[{0}] Creating movie set {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), name));
            _context.SaveChanges();

            return(movieSet);
        }
Esempio n. 7
0
        public bool CheckUserId(int?id, IHttpContextAccessor httpContextAccessor)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Null");
            }

            var userid = currentUserService.GetCurrentUserId(httpContextAccessor);

            MovieSet movieSet = repoMovieSet.GetSingle(id);

            return(userid.Equals(movieSet.UserID));
        }
        private async Task MoveImages()
        {
            MovieSet oldSet = await _metadataService.GetMovieSet(DisplayName);

            MovieSet newSet = await _metadataService.GetMovieSet(SetName);

            await _fileSystemService.MoveFile(oldSet.BackdropPath, newSet.BackdropPath);

            await _fileSystemService.MoveFile(oldSet.PosterPath, newSet.PosterPath);

            Fanart.Path = newSet.BackdropPath;
            Poster.Path = newSet.PosterPath;
        }
Esempio n. 9
0
        public HttpResponseMessage Get()
        {
            try
            {
                List <IMovieSet> movieSets = new List <IMovieSet>();

                foreach (IProvider provider in this.providersDictionary.Values)
                {
                    HttpStatusCode statusCode;
                    string         movies = httpService.Get(provider.GetAPI, out statusCode);
                    if (statusCode != HttpStatusCode.OK)
                    {
                        return(new HttpResponseMessage(statusCode));
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(movies))
                        {
                            MovieSet movieSet = new MovieSet()
                            {
                                Movies = movies, Provider = provider.Name
                            };
                            movieSets.Add(movieSet);
                        }
                    }
                }

                var jsonMovieSets = new JavaScriptSerializer().Serialize(movieSets);

                var newReponse = Request.CreateResponse(HttpStatusCode.OK);
                newReponse.Content = new StringContent(jsonMovieSets, Encoding.UTF8, Constants.APPLICATION_JSON);
                return(newReponse);
            }
            catch (Exception)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Esempio n. 10
0
        public bool CheckMovie(RepositoryMovieSet repomovieset, MyMovie myMovie)
        {
            MovieSet movieset = repomovieset.Get(myMovie.MovieSetID);

            return(movieset.MyMovies.Any(e => e.MovieID == myMovie.MovieID));
        }
 public MovieSetControl(object parent, MovieSet movieSet) : base(parent)
 {
     InitializeComponent();
     this.MovieSet = movieSet;
 }
 protected CutsceneUpdateProtocol(Cutscene cutscene, MovieSet set) : base(cutscene, set)
 {
 }
Esempio n. 13
0
        public static async void Initialize(ApplicationContext applicationContext, UserManager <ApplicationUser> userManager)
        {
            applicationContext.Database.EnsureCreated();

            if (applicationContext.Movies.Any())
            {
                return;
            }

            ApplicationUser user = new ApplicationUser
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true
            };
            IdentityResult result = await userManager.CreateAsync(user, "HereComesJohnny!123");

            if (!result.Succeeded)
            {
                throw new Exception("Couldn't initialize user");
            }


            //applicationContext.Users.Add(user);
            //applicationContext.SaveChanges();
            var movies = new Movie[]
            {
                new Movie {
                    MovieName = "Donnie Darko", TMDb = 1, MovieYear = "2001", MovieDescription = "", MovieIcon = "", MovieRating = 8.1, MovieGenre = "Drama, Sci-Fi, Thriller",
                },
                new Movie {
                    MovieName = "Inception", TMDb = 2, MovieYear = "2010", MovieDescription = "", MovieIcon = "", MovieRating = 8.8, MovieGenre = "Action, Adventure, Sci-Fi",
                },
                new Movie {
                    MovieName = "Pan's Labyrinth", TMDb = 3, MovieYear = "2006", MovieDescription = "", MovieIcon = "", MovieRating = 8.2, MovieGenre = "Drama, Fantasy, War",
                },
                new Movie {
                    MovieName = "A Beautiful Mind", TMDb = 4, MovieYear = "2001", MovieDescription = "", MovieIcon = "", MovieRating = 8.2, MovieGenre = "Biography, Drama",
                },
            };

            foreach (Movie m in movies)
            {
                applicationContext.Movies.Add(m);
            }
            applicationContext.SaveChanges();

            var moviesets = new MovieSet[]
            {
                new MovieSet {
                    UserID = user.Id, SetName = "SF", CreationDate = DateTime.Parse("2005-09-01"),
                },
                new MovieSet {
                    UserID = user.Id, SetName = "Drama", CreationDate = DateTime.Parse("2015-10-07"),
                },
                new MovieSet {
                    UserID = user.Id, SetName = "Filme3", CreationDate = DateTime.Parse("2014-11-13"),
                },
                new MovieSet {
                    UserID = user.Id, SetName = "Filme4", CreationDate = DateTime.Parse("2013-09-15"),
                },
            };

            foreach (MovieSet l in moviesets)
            {
                applicationContext.MovieSets.Add(l);
            }
            applicationContext.SaveChanges();

            var mymovies = new MyMovie[]
            {
                new MyMovie {
                    MyMovieRating = 9.5,
                    MovieID       = movies.Single(s => s.MovieName == "Donnie Darko").MovieID,
                    MovieSetID    = moviesets.Single(s => s.SetName == "SF").MovieSetID,
                },
                new MyMovie {
                    MyMovieRating = 9,
                    MovieID       = movies.Single(s => s.MovieName == "Inception").MovieID,
                    MovieSetID    = moviesets.Single(s => s.SetName == "SF").MovieSetID,
                },
                new MyMovie {
                    MyMovieRating = 9.3,
                    MovieID       = movies.Single(s => s.MovieName == "Pan's Labyrinth").MovieID,
                    MovieSetID    = moviesets.Single(s => s.SetName == "Drama").MovieSetID,
                },
                new MyMovie {
                    MyMovieRating = 9,
                    MovieID       = movies.Single(s => s.MovieName == "A Beautiful Mind").MovieID,
                    MovieSetID    = moviesets.Single(s => s.SetName == "Drama").MovieSetID,
                },
            };

            foreach (MyMovie my in mymovies)
            {
                applicationContext.MyMovies.Add(my);
            }

            var genres = new TMDbGenre[]
            {
                new TMDbGenre {
                    TMDbID = 28, Name = "Action"
                },
                new TMDbGenre {
                    TMDbID = 12, Name = "Adventure"
                },
                new TMDbGenre {
                    TMDbID = 16, Name = "Animation"
                },
                new TMDbGenre {
                    TMDbID = 35, Name = "Comedy"
                },
                new TMDbGenre {
                    TMDbID = 80, Name = "Crime"
                },
                new TMDbGenre {
                    TMDbID = 99, Name = "Documemntary"
                },
                new TMDbGenre {
                    TMDbID = 18, Name = "Drama"
                },
                new TMDbGenre {
                    TMDbID = 10751, Name = "Family"
                },
                new TMDbGenre {
                    TMDbID = 14, Name = "Fantasy"
                },
                new TMDbGenre {
                    TMDbID = 36, Name = "History"
                },
                new TMDbGenre {
                    TMDbID = 27, Name = "Horror"
                },
                new TMDbGenre {
                    TMDbID = 10402, Name = "Music"
                },
                new TMDbGenre {
                    TMDbID = 9648, Name = "Mystery"
                },
                new TMDbGenre {
                    TMDbID = 10749, Name = "Romance"
                },
                new TMDbGenre {
                    TMDbID = 878, Name = "Science Fiction"
                },
                new TMDbGenre {
                    TMDbID = 10770, Name = "TV Movie"
                },
                new TMDbGenre {
                    TMDbID = 53, Name = "Thriller"
                },
                new TMDbGenre {
                    TMDbID = 10752, Name = "War"
                },
                new TMDbGenre {
                    TMDbID = 37, Name = "Western"
                },
            };

            foreach (TMDbGenre g in genres)
            {
                applicationContext.TMDbGenres.Add(g);
            }

            applicationContext.SaveChanges();
        }