Ejemplo n.º 1
0
        protected override async Task OnInitializedAsync()
        {
            var keys = await GetRecentlyViewedKeys();

            if (keys is not null && keys.Count() is not 0)
            {
                foreach (var key in keys)
                {
                    if (key.Contains("movie"))
                    {
                        var movie = await LocalStorage.GetItemAsync <MovieDetails>(key);

                        Movies.Add(movie);
                    }

                    if (key.Contains("tv"))
                    {
                        var tvShow = await LocalStorage.GetItemAsync <TVShowDetails>(key);

                        TVShows.Add(tvShow);
                    }
                }
            }

            if (Movies.Count() is 0 && TVShows.Count() is 0)
            {
                DisplayMessage = true;
                Message        = "There is no recently viewed items.";
            }
        }
Ejemplo n.º 2
0
        public ActionResult TV()
        {
            TVShows currentTVShow = new TVShows();

            currentTVShow.TVShowId = ViewBag.Messege;
            return(View(currentTVShow));
        }
Ejemplo n.º 3
0
        public List <TVShows> GetRandomShow()
        {
            DataSet          myDS    = new DataSet();
            StoredProcedures stoPros = new StoredProcedures();

            myDS = stoPros.getRandShow();

            DBConnect objDB = new DBConnect();

            TVShows        shows = new TVShows();
            List <TVShows> dpts  = new List <TVShows>();

            foreach (DataRow dr in myDS.Tables[0].Rows)
            {
                shows                 = new TVShows();
                shows.ShowID          = int.Parse(dr["TV_Show_ID"].ToString());
                shows.ShowImage       = dr["TV_Show_Image"].ToString();
                shows.ShowName        = dr["TV_Show_Name"].ToString();
                shows.ShowYears       = dr["TV_Show_Years"].ToString();
                shows.ShowAgeRating   = dr["TV_Show_Age_Rating"].ToString();
                shows.ShowRuntime     = int.Parse(dr["TV_Show_Runtime"].ToString());
                shows.ShowGenre       = dr["TV_Show_Genre"].ToString();
                shows.ShowDescription = dr["TV_Show_Description"].ToString();

                dpts.Add(shows);
            }
            return(dpts);
        }
Ejemplo n.º 4
0
        public ActionResult GetTVShow(int tvShowId)
        {
            try
            {
                TVShows tvshow = database.TVShows.AsNoTracking().SingleOrDefault(i => i.ID == tvShowId);

                return(Json(tvshow));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes the specified TV show from the database.
        /// </summary>
        /// <param name="show">The TV show to remove.</param>
        /// <param name="callback">The status callback.</param>
        /// <returns>
        ///   <c>true</c> on success; otherwise, <c>false</c>.
        /// </returns>
        public static bool Remove(TVShow show, Action <int, string> callback = null)
        {
            Log.Info("Removing " + show.Title + "...");

            if (callback != null)
            {
                callback(0, "Removing " + show.Title + "...");
            }

            try
            {
                Directory.Delete(show.Directory, true);
            }
            catch (Exception ex)
            {
                Log.Error("Error while removing " + show.Title + ".", ex);

                if (callback != null)
                {
                    callback(-1, "Could not remove database for " + show.Title + ".");
                }

                return(false);
            }

            TVShows.Remove(show.ID);
            DataChange = DateTime.Now;

            if (Library.Files != null && Library.Files.Count != 0)
            {
                foreach (var ep in Library.Files)
                {
                    if (Math.Floor((double)ep.Key / 1000 / 1000) == show.ID)
                    {
                        ep.Value.Clear();
                    }
                }

                Library.SaveList();
            }

            if (callback != null)
            {
                callback(1, "Removed " + show.Title + ".");
            }

            return(true);
        }
        public async Task <ActionResult <int> > Post([FromBody] CreateTvShowCommand command)
        {
            var entity = new TVShows
            {
                Name        = command.Name,
                Genre       = command.Genre,
                Director    = command.Director,
                ReleaseYear = command.ReleaseYear
            };

            _context.TVShows.Add(entity);

            await _context.SaveChangesAsync();

            return(Ok(entity.Id));
        }
Ejemplo n.º 7
0
        public ActionResult DeleteTVShow(int id)
        {
            try
            {
                TVShows tvShow = database.TVShows.AsNoTracking().SingleOrDefault(i => i.ID == id);

                database.Entry(tvShow).State = EntityState.Deleted;

                database.SaveChanges();

                return(Json("TV Show Deleted!"));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
Ejemplo n.º 8
0
        public ActionResult SaveTVShow(TVShows tvshow)
        {
            try
            {
                List <TVShows> tvshows = database.TVShows.AsNoTracking().ToList();

                if (tvshow != null)
                {
                    if (tvshow.Title == null)
                    {
                        return(Json("A title is required"));
                    }

                    if (tvshow.Year == null)
                    {
                        return(Json("A year is required"));
                    }

                    foreach (TVShows tv in tvshows)
                    {
                        if (tvshow.Title == tv.Title && tvshow.Year == tv.Year)
                        {
                            return(Json("A TV show with this title and year already exists"));
                        }
                    }

                    if (tvshow.ID == 0)
                    {
                        database.Entry(tvshow).State = EntityState.Added;
                    }

                    else
                    {
                        database.Entry(tvshow).State = EntityState.Modified;
                    }
                }

                database.SaveChanges();

                return(View("Media.TVShows"));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
Ejemplo n.º 9
0
        protected async Task HandleClearBtnClick()
        {
            var keys = await GetRecentlyViewedKeys();

            if (keys is not null && keys.Count() is not 0)
            {
                foreach (var key in keys)
                {
                    await LocalStorage.RemoveItemAsync(key);
                }

                Movies.Clear();
                TVShows.Clear();

                DisplayMessage = true;
                Message        = "There is no recently viewed items.";

                StateHasChanged();
            }
        }
Ejemplo n.º 10
0
        public void Lookup()
        {
            try
            {
                var vm = LookupViewModel.Create();

                var result = this.DialogService.ShowDialog(
                    dialogCommands: vm.DialogCommands,
                    title: "TV Show Lookup",
                    documentType: "LookupView",
                    parameter: null,
                    parentViewModel: this,
                    viewModel: vm);

                if (result != null && result.IsDefault)
                {
                    this.SplashScreenService.ShowSplashScreen();

                    TVShows show = new TVShows()
                    {
                        Title       = vm.ShowName,
                        MazeId      = vm.ShowId,
                        Synopsis    = vm.Synopsis,
                        Image       = vm.ShowImage,
                        NextAirDate = vm.NextAirDate
                    };

                    show.Save();
                    this.Shows.Add(show);
                    this.SplashScreenService.HideSplashScreen();
                }
            }
            catch (Exception ex)
            {
                this.SplashScreenService.HideSplashScreen();
                this.MessageBoxService.ShowMessage(ex.Message, "Error");
            }
        }
Ejemplo n.º 11
0
 public void Delete(TVShows show)
 {
     if (this.MessageBoxService.ShowMessage("Are you sure you wish to delete the selected show?", "Confirm", MessageButton.YesNo, MessageIcon.Question) == MessageResult.Yes)
     {
         try
         {
             this.SplashScreenService.ShowSplashScreen();
             using (tgTransactionScope scope = new tgTransactionScope())
             {
                 show.MarkAsDeleted();
                 this.TVShowsCollection.Save();
                 this.Shows.Remove(show);
                 scope.Complete();
             }
             this.SplashScreenService.HideSplashScreen();
         }
         catch (Exception ex)
         {
             this.SplashScreenService.HideSplashScreen();
             this.MessageBoxService.ShowMessage(ex.Message, "Error");
         }
     }
 }
Ejemplo n.º 12
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = PlayListID;
         hashCode = (hashCode * 397) ^ Name.GetHashCode();
         hashCode = (hashCode * 397) ^ Master.GetHashCode();
         hashCode = (hashCode * 397) ^ PlayListID.GetHashCode();
         hashCode = (hashCode * 397) ^ PlaylistPersistentID.GetHashCode();
         hashCode = (hashCode * 397) ^ ParentPersistentID.GetHashCode();
         hashCode = (hashCode * 397) ^ Visible.GetHashCode();
         hashCode = (hashCode * 397) ^ AllItems.GetHashCode();
         hashCode = (hashCode * 397) ^ DistinguishedKind.GetHashCode();
         hashCode = (hashCode * 397) ^ Movies.GetHashCode();
         hashCode = (hashCode * 397) ^ TVShows.GetHashCode();
         hashCode = (hashCode * 397) ^ PodCasts.GetHashCode();
         hashCode = (hashCode * 397) ^ iTunesU.GetHashCode();
         hashCode = (hashCode * 397) ^ Audiobooks.GetHashCode();
         hashCode = (hashCode * 397) ^ Books.GetHashCode();
         hashCode = (hashCode * 397) ^ Folder.GetHashCode();
         hashCode = (hashCode * 397) ^ PlaylistItems.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 13
0
 public bool CanDelete(TVShows show)
 {
     return(show != null);
 }
Ejemplo n.º 14
0
        public IActionResult SaveRequest(Request request)
        {
            try
            {
                List <Request> requests = database.Requests.AsNoTracking().ToList();

                Movie movie = new Movie();

                TVShows tvShow = new TVShows();

                requestTypes = database.RequestTypes.AsNoTracking().Where(i => i.Enabled == true).ToList();

                requestUsers = database.RequestUsers.AsNoTracking().Where(i => i.Active == true).ToList();

                ViewBag.requestTypes = requestTypes;

                ViewBag.requestUsers = requestUsers;

                if (request != null)
                {
                    if (request.IsComplete)
                    {
                        switch (request.Type)
                        {
                        case "Movie":
                            movie.Title = request.Title;
                            movie.YYYY  = request.Year;
                            database.Entry(movie).State = EntityState.Added;
                            break;
                        }

                        switch (request.Type)
                        {
                        case "TV Show":
                            tvShow.Title = request.Title;
                            tvShow.Year  = request.Year;
                            database.Entry(tvShow).State = EntityState.Added;
                            break;
                        }
                    }

                    if (request.Title == null)
                    {
                        return(Json("A title is required"));
                    }

                    if (request.Year == null)
                    {
                        return(Json("A year is required"));
                    }

                    if (request.RequestedBy == null)
                    {
                        return(Json("A name is required"));
                    }

                    request.RequestedDate = DateTime.Now;

                    foreach (Request r in requests)
                    {
                        if (request.Title == r.Title && request.Year == r.Year && r.ID != request.ID)
                        {
                            return(Json("This request has already been made by " + r.RequestedBy + " on " + r.RequestedDate.ToString("dd/MM/yyyy")));
                        }
                    }

                    if (request.ID == 0)
                    {
                        database.Entry(request).State = EntityState.Added;
                    }

                    else
                    {
                        database.Entry(request).State = EntityState.Modified;
                    }

                    database.SaveChanges();
                }

                return(View("Request.Home"));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
Ejemplo n.º 15
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Session["NewMovieInfo"] != null || Session["AddNewMovie"] != null)
            {
                if (ddlAddMovieAgeRange.SelectedValue == "noneSelected")
                {
                    lblDisplay.Text = "Select an Age Rating";
                }
                else
                {
                    if (ddlAddMovieGenre.SelectedValue == "noneSelected")
                    {
                        lblDisplay.Text = "Select a Genre";
                    }
                    else
                    {
                        if (ddlAddMovieYear.SelectedValue == "noneSelected")
                        {
                            lblDisplay.Text = "Select a Year";
                        }
                        else
                        {
                            Movies movie = new Movies();

                            movie.memberID = Convert.ToInt32(Session["MemberID"].ToString());
                            if (Session["Edit_ID"] != null)
                            {
                                movie.movieID = Convert.ToInt32(Session["Edit_ID"].ToString());
                            }
                            movie.movieImage       = txtAddMovieImage.Text;
                            movie.movieName        = txtAddMovieName.Text;
                            movie.movieYear        = Convert.ToInt32(ddlAddMovieYear.Text);
                            movie.movieDescription = txtAddMovieDescription.Text;
                            movie.movieRuntime     = Convert.ToInt32(txtAddMovieRuntime.Text);
                            movie.movieAgeRating   = ddlAddMovieAgeRange.Text;
                            movie.movieGenre       = ddlAddMovieGenre.Text;
                            movie.movieBudget      = float.Parse(txtAddMovieBudget.Text);
                            movie.movieIncome      = float.Parse(txtAddMovieIncome.Text);

                            JavaScriptSerializer js = new JavaScriptSerializer();

                            String jsonMovie = js.Serialize(movie);

                            try
                            {
                                if (Session["NewMovieInfo"] != null)
                                {
                                    WebRequest request = WebRequest.Create("https://localhost:44301/WebAPI/movies/UpdateMovie/");
                                    request.Method        = "PUT";
                                    request.ContentLength = jsonMovie.Length;
                                    request.ContentType   = "application/json";

                                    // Write the JSON data to the Web Request
                                    StreamWriter writer = new StreamWriter(request.GetRequestStream());
                                    writer.Write(jsonMovie);
                                    writer.Flush();
                                    writer.Close();

                                    // Read the data from the Web Response, which requires working with streams.
                                    WebResponse  response      = request.GetResponse();
                                    Stream       theDataStream = response.GetResponseStream();
                                    StreamReader reader        = new StreamReader(theDataStream);
                                    String       data          = reader.ReadToEnd();
                                    reader.Close();
                                    response.Close();

                                    if (data == "true")
                                    {
                                        lblDisplay.Text = "The movie was successfully edited.";

                                        Response.Write("<script>alert('Movie Updated successfully')</script>");
                                    }

                                    else
                                    {
                                        lblDisplay.Text = "Make sure you are only editting your own added listing!";
                                    }
                                }
                                else
                                {
                                    WebRequest request = WebRequest.Create("https://localhost:44301/WebAPI/movies/AddMovie/");
                                    request.Method = "POST";

                                    request.ContentType   = "application/json";
                                    request.ContentLength = jsonMovie.Length;

                                    // Write the JSON data to the Web Request
                                    StreamWriter writer = new StreamWriter(request.GetRequestStream());
                                    writer.Write(jsonMovie);
                                    writer.Flush();
                                    writer.Close();

                                    // Read the data from the Web Response, which requires working with streams.
                                    WebResponse  response      = request.GetResponse();
                                    Stream       theDataStream = response.GetResponseStream();
                                    StreamReader reader        = new StreamReader(theDataStream);
                                    String       data          = reader.ReadToEnd();
                                    reader.Close();
                                    response.Close();

                                    if (data == "true")
                                    {
                                        lblDisplay.Text = "The movie was successfully saved to the database.";

                                        Response.Write("<script>alert('Movie inserted successfully')</script>");
                                    }
                                    else
                                    {
                                        lblDisplay.Text = "A problem occurred while adding the movie to the database. The data wasn't recorded.";
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                lblDisplay.Text = "Error: " + ex.Message;
                            }
                        }
                    }
                }
                Session["NewMovieInfo"] = null;
            }
            else if (Session["NewShowInfo"] != null || Session["AddNewShow"] != null)
            {
                if (ddlAddShowAgeRating.SelectedValue == "noneSelected")
                {
                    lblDisplay2.Text = "Please Select an Age Rating";
                }
                else
                {
                    if (ddlAddShowGenre.SelectedValue == "noneSelected")
                    {
                        lblDisplay2.Text = "Please Select a Genre";
                    }
                    else
                    {
                        if (ddlAddShowYearsStart.SelectedValue == "noneSelected")
                        {
                            lblDisplay2.Text = "Please Select Run Years Value";
                        }
                        else
                        {
                            if (ddlAddShowYearsEnd.SelectedValue == "noneSelected")
                            {
                                lblDisplay2.Text = "Please Select Run Years Value";
                            }
                            else
                            {
                                TVShows show = new TVShows();
                                show.MemberID = Convert.ToInt32(Session["MemberID"].ToString());

                                if (Session["Edit_ID"] != null)
                                {
                                    show.ShowID = Convert.ToInt32(Session["Edit_ID"].ToString());
                                }
                                show.ShowImage       = txtAddShowImage.Text;
                                show.ShowName        = txtAddShowName.Text;
                                show.ShowYears       = ddlAddShowYearsStart.Text + "-" + ddlAddShowYearsEnd.Text;
                                show.ShowAgeRating   = ddlAddShowAgeRating.Text;
                                show.ShowRuntime     = Convert.ToInt32(txtAddShowRuntime.Text);
                                show.ShowGenre       = ddlAddShowGenre.Text;
                                show.ShowDescription = txtAddShowDescription.Text;

                                JavaScriptSerializer js = new JavaScriptSerializer();

                                String jsonShow = js.Serialize(show);

                                try
                                {
                                    if (Session["NewShowInfo"] != null)
                                    {
                                        WebRequest request = WebRequest.Create("https://localhost:44301/WebAPI/show/UpdateShow/");
                                        request.Method        = "PUT";
                                        request.ContentLength = jsonShow.Length;
                                        request.ContentType   = "application/json";

                                        // Write the JSON data to the Web Request
                                        StreamWriter writer = new StreamWriter(request.GetRequestStream());
                                        writer.Write(jsonShow);
                                        writer.Flush();
                                        writer.Close();

                                        // Read the data from the Web Response, which requires working with streams.
                                        WebResponse  response      = request.GetResponse();
                                        Stream       theDataStream = response.GetResponseStream();
                                        StreamReader reader        = new StreamReader(theDataStream);
                                        String       data          = reader.ReadToEnd();
                                        reader.Close();
                                        response.Close();

                                        if (data == "true")
                                        {
                                            Response.Write("<script>alert('Show updated successfully')</script>");
                                        }
                                        //  lblDisplay.Text = "The Show was successfully edited.";
                                        else
                                        {
                                            lblDisplay2.Text = "Make sure you are only editting your own added listing!";
                                        }
                                    }
                                    else
                                    {
                                        WebRequest request = WebRequest.Create("https://localhost:44301/WebAPI/show/AddShow/");
                                        request.Method        = "POST";
                                        request.ContentLength = jsonShow.Length;
                                        request.ContentType   = "application/json";

                                        // Write the JSON data to the Web Request
                                        StreamWriter writer = new StreamWriter(request.GetRequestStream());
                                        writer.Write(jsonShow);
                                        writer.Flush();
                                        writer.Close();

                                        // Read the data from the Web Response, which requires working with streams.
                                        WebResponse  response      = request.GetResponse();
                                        Stream       theDataStream = response.GetResponseStream();
                                        StreamReader reader        = new StreamReader(theDataStream);
                                        String       data          = reader.ReadToEnd();
                                        reader.Close();
                                        response.Close();

                                        if (data == "true")
                                        {
                                            Response.Write("<script>alert('Show inserted successfully')</script>");
                                        }
                                        //lblDisplay.Text = "The show was successfully saved to the database.";
                                        else
                                        {
                                            lblDisplay2.Text = "A problem occurred while adding the show to the database. The data wasn't recorded.";
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    lblDisplay2.Text = "Error: " + ex.Message;
                                }
                            }
                        }
                    }
                }
                Session["NewShowInfo"] = null;
            }
            else if (Session["NewGameInfo"] != null || Session["AddNewGame"] != null)
            {
                if (ddlAddGameAgeRating.SelectedValue == "noneSelected")
                {
                    lblDisplay3.Text = "Please Select Age Rating";
                }
                else
                {
                    if (ddlAddGameGenre.SelectedValue == "noneSelected")
                    {
                        lblDisplay3.Text = "Please Select Genre";
                    }
                    else
                    {
                        if (ddlAddGameYear.SelectedValue == "noneSelected")
                        {
                            lblDisplay3.Text = "Please Select Release Year";
                        }
                        else
                        {
                            VideoGames game = new VideoGames();
                            game.MemberID = Convert.ToInt32(Session["MemberID"].ToString());

                            if (Session["Edit_ID"] != null)
                            {
                                game.GameID = Convert.ToInt32(Session["Edit_ID"].ToString());
                            }
                            game.GameImage       = txtAddGameImage.Text;
                            game.GameName        = txtAddGameName.Text;
                            game.GameYear        = Convert.ToInt32(ddlAddGameYear.Text);
                            game.GameGenre       = ddlAddGameGenre.Text;
                            game.GameDescription = txtAddGameDescription.Text;
                            game.GameCreator     = txtAddGameCreator.Text;
                            game.GameAgeRating   = ddlAddGameAgeRating.Text;

                            JavaScriptSerializer js = new JavaScriptSerializer();

                            String jsonGame = js.Serialize(game);

                            try
                            {
                                if (Session["NewGameInfo"] != null)
                                {
                                    WebRequest request = WebRequest.Create("https://localhost:44301/WebAPI/game/UpdateGame/");
                                    request.Method        = "PUT";
                                    request.ContentLength = jsonGame.Length;
                                    request.ContentType   = "application/json";

                                    // Write the JSON data to the Web Request
                                    StreamWriter writer = new StreamWriter(request.GetRequestStream());
                                    writer.Write(jsonGame);
                                    writer.Flush();
                                    writer.Close();

                                    // Read the data from the Web Response, which requires working with streams.
                                    WebResponse  response      = request.GetResponse();
                                    Stream       theDataStream = response.GetResponseStream();
                                    StreamReader reader        = new StreamReader(theDataStream);
                                    String       data          = reader.ReadToEnd();
                                    reader.Close();
                                    response.Close();

                                    if (data == "true")
                                    {
                                        Response.Write("<script>alert('Game updated successfully')</script>");
                                    }
                                    //lblDisplay.Text = "The game was successfully edited.";
                                    else
                                    {
                                        lblDisplay3.Text = "Make sure you are only editting your own added listing!";
                                    }
                                }
                                else
                                {
                                    WebRequest request = WebRequest.Create("https://localhost:44301/WebAPI/game/AddGame/");
                                    request.Method        = "POST";
                                    request.ContentLength = jsonGame.Length;
                                    request.ContentType   = "application/json";

                                    // Write the JSON data to the Web Request
                                    StreamWriter writer = new StreamWriter(request.GetRequestStream());
                                    writer.Write(jsonGame);
                                    writer.Flush();
                                    writer.Close();

                                    // Read the data from the Web Response, which requires working with streams.
                                    WebResponse  response      = request.GetResponse();
                                    Stream       theDataStream = response.GetResponseStream();
                                    StreamReader reader        = new StreamReader(theDataStream);
                                    String       data          = reader.ReadToEnd();
                                    reader.Close();
                                    response.Close();

                                    if (data == "true")
                                    {
                                        Response.Write("<script>alert('Game added successfully')</script>");
                                    }
                                    //lblDisplay.Text = "The game was successfully saved to the database.";
                                    else
                                    {
                                        lblDisplay3.Text = "A problem occurred while adding the game to the database. The data wasn't recorded.";
                                    }
                                }
                            }

                            catch (Exception ex)
                            {
                                lblDisplay.Text = "Error: " + ex.Message;
                            }
                        }
                    }
                }
            }
            Session["NewGameInfo"] = null;
        }