Пример #1
0
 protected void GiftButton_Click(object sender, EventArgs e)
 {
     try
     {
         // If a user does not have a gift registry create one
         int giftRegistryID = GiftRegistries.GetGiftRegistry(0, GetLoggedCustomerID(), string.Empty, false).GiftRegistryID;
         if (giftRegistryID == 0)
         {
             GiftRegistry giftRegistry = new GiftRegistry()
             {
                 CustomerID = GetLoggedCustomerID(), DateCreated = DateTime.Now, Active = true
             };
             giftRegistryID = GiftRegistries.AddGiftRegistry(giftRegistry);
         }
         // Add this product
         GiftRegistries.AddGiftRegistryProduct(new GiftRegistryProduct()
         {
             GiftRegistryID = giftRegistryID, ProductID = CartProduct.ProductID, Active = true
         });
         Response.Redirect("MyAccount/GiftRegistry.aspx");
     }
     catch (Exception ex)
     {
         ((Button)sender).Text = "Error " + ex.Message;
     }
 }
Пример #2
0
    protected void VisibilityRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (giftRegistry == null)
        {
            giftRegistry = GiftRegistries.GetGiftRegistry(0, GetLoggedCustomerID(), string.Empty, true);
        }

        // Create a registry if it doesnt exist
        if (giftRegistry.GiftRegistryID == 0)
        {
            giftRegistry = new GiftRegistry()
            {
                CustomerID = GetLoggedCustomerID(), DateCreated = DateTime.Now, Active = true
            };
            giftRegistry.GiftRegistryID = GiftRegistries.AddGiftRegistry(giftRegistry);
        }
        GiftRegistries.UpdateGiftRegistryPublic(giftRegistry.GiftRegistryID, Convert.ToBoolean(VisibilityRadioButtonList.SelectedValue));
    }