Пример #1
0
        //Method that extracts all data to populate the tables
        private void LoadData(LoadDataArgs e)
        {
            IUser UserServices = new UserServices();
            //UserID extraction from DataBase
            Guid UserID = UserServices.GetUserID(e.UserName);

            IList<UserCommentDTO> ListOfComments = UserServices.GetAllUserComments(UserID);
            IList<UserRatingDTO> ListOfRatings = UserServices.GetAllUserRatings(UserID);
            IList<UserFavoriteMovieDTO> ListOfFavoriteMovies = UserServices.GetFavoriteMoviesByUser(UserID);
            IList<String> ListOfMovies = UserServices.GetMoviesToWhichTheUserCommented(UserID);

            //Data transfer to MyAre MODEL
            Myview.Model.ListOfComments = new List<CommentLine>();
            Myview.Model.ListOfRatings = new List<RatingLine>();
            Myview.Model.ListOfFavorites = new List<FavoriteLine>();
            Myview.Model.ListOfMovies = new List<String>();
            foreach (var item in ListOfComments)
            {
                CommentLine row = new CommentLine();
                row.CommentID = item.commentID;
                row.MovieTitle = item.MovieTitle;
                row.CommentContent = item.Content;
                row.MovieID = item.movieID;
                Myview.Model.ListOfComments.Add(row);
            }

            foreach (var item in ListOfMovies)
            {
                String row1 = null;
                row1 = item;
                bool check = Myview.Model.ListOfMovies.Contains(row1);
                if (!check)
                {
                    Myview.Model.ListOfMovies.Add(row1);
                }
            }

            foreach (var item in ListOfRatings)
            {
                RatingLine row = new RatingLine();
                row.MovieTitle = item.MovieTitle;
                row.Rating = item.rate.ToString();
                Myview.Model.ListOfRatings.Add(row);

            }

            foreach (var item in ListOfFavoriteMovies)
            {
                FavoriteLine row = new FavoriteLine();
                row.MovieTitle = item.MovieTitle;
                Myview.Model.ListOfFavorites.Add(row);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (this.LoadData != null)
                {
                    var ex = new LoadDataArgs();
                    ex.UserName = System.Web.HttpContext.Current.User.Identity.Name;
                    LoadData(ex);
                }

                GridViewRating.DataSource = Model.ListOfRatings;
                GridViewRating.DataBind();

                GridViewFavorite.DataSource = Model.ListOfFavorites;
                GridViewFavorite.DataBind();

                PopulateTreeView();
                trvComments.CollapseAll();

            }
        }
 protected void GridViewFavorite_SelectedIndexChanged(object sender, EventArgs e)
 {
     GridViewRow row = GridViewFavorite.SelectedRow;
     string selectedMovieTitle = row.Cells[0].Text;
     GridUpdateArgs gua = new GridUpdateArgs();
     gua.ID = selectedMovieTitle;
     gua.UserName = System.Web.HttpContext.Current.User.Identity.Name;
     if (RemoveMovie != null)
     {
         RemoveMovie(gua);
         if (Model.IsValidTransastion == true)
         {
             var ex = new LoadDataArgs();
             ex.UserName = System.Web.HttpContext.Current.User.Identity.Name;
             LoadData(ex);
             GridViewFavorite.DataSource = Model.ListOfFavorites;
             GridViewFavorite.DataBind();
         }
     }
 }