Exemple #1
0
    /// <summary>
    /// Helper adds image to favorites
    /// </summary>
    /// <param name="item"></param>
    private void AddImageToFavorites(ListViewItem item)
    {
        // Retrieve item index
        int index = Convert.ToInt32(item.DisplayIndex);

        // Initialize object
        TravelImage image = new TravelImage();

        image.Id    = Convert.ToInt32(lvImageData.DataKeys[index].Values["Id"]);;
        image.Title = lvImageData.DataKeys[index].Values["Title"].ToString();
        image.Path  = lvImageData.DataKeys[index].Values["Path"].ToString();

        // Save to session (favorites)
        FavoritesSessionFacade.Add(image);
    }
Exemple #2
0
    /// <summary>
    /// Event handler for the lvPostData_ItemCommand event
    /// </summary>
    /// <param name="sender">a sender</param>
    /// <param name="e">a e</param>
    protected void lvPostData_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // Retrieve item which raised item command event
        ListViewItem item = (ListViewItem)e.Item;

        // Retrieve item index
        int index = Convert.ToInt32(item.DisplayIndex);

        // Initialize object
        TravelPost post = new TravelPost();

        post.Id    = Convert.ToInt32(lvPostData.DataKeys[index].Values["Id"]);;
        post.Title = lvPostData.DataKeys[index].Values["Title"].ToString();;

        // Save to session (favorites)
        FavoritesSessionFacade.Add(post);

        // Redirect to favorites page upon redirect
        Response.Redirect("./Favorites.aspx");
    }
Exemple #3
0
    /// <summary>
    /// Event handler for rptImageBox_ItemCommand event
    /// </summary>
    /// <param name="sender">a sender</param>
    /// <param name="e">a e</param>
    protected void rptImageBox_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // Retrieve item which raised item command event
        ListViewItem item = (ListViewItem)e.Item;

        // Retrieve item index
        int index = Convert.ToInt32(item.DisplayIndex);

        // Initialize object
        TravelImage image = new TravelImage();

        image.Id    = Convert.ToInt32(lvImageBox.DataKeys[index].Values["Id"]);;
        image.Title = lvImageBox.DataKeys[index].Values["Title"].ToString();;
        image.Path  = lvImageBox.DataKeys[index].Values["Path"].ToString();;

        // Save to session
        FavoritesSessionFacade.Add(image);

        // Redirect to favorites page upon adding
        Response.Redirect("./Favorites.aspx");
    }
Exemple #4
0
    /// <summary>
    /// Event handler for the gvPost_RowCommand event
    /// </summary>
    /// <param name="sender">a sender</param>
    /// <param name="e">a e</param>
    protected void gvPost_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "addFavorite")
        {
            // Retrieve index of row generating event
            int index = Convert.ToInt32(e.CommandArgument);

            // Retrieve the id of the object bound to row
            int id = Convert.ToInt32(gvPost.DataKeys[index].Values["Id"].ToString());

            // Initialize object
            TravelPost post = new TravelPost();
            post.Id    = id;
            post.Title = gvPost.DataKeys[index].Values["Title"].ToString();

            // Add to session
            FavoritesSessionFacade.Add(post);

            // Redirect to favorites page
            Response.Redirect("./Favorites.aspx");
        }
    }