public void AddAnnouncementTest()
 {
     //int AddAnnouncement(int moduleId, int itemId, String userName, String title, DateTime expireDate,
     //                String description, String moreLink, String mobileMoreLink)
     DesktopModulesFacade facade = new DesktopModulesFacade();
     PortalAnnouncement announcement = new PortalAnnouncement();
     announcement.ModuleID = 0;
     announcement.ItemID = 0;
     announcement.CreatedByUser = "******";
     announcement.Title = "t";
     announcement.Description = "d";
     announcement.ExpireDate = new DateTime(2011, 1, 1);
     announcement.MoreLink = "ml";
     announcement.MobileMoreLink = "mml";
     facade.AddAnnouncement(announcement);
 }
        public int AddAnnouncement(PortalAnnouncement announcement)
        {
            // TODO: add access security here..
            // TODO: add argument validation here..

            int retval;
            // Run within the context of a database transaction.
            // The Decorator Design Pattern.
            using (TransactionDecorator transaction = new TransactionDecorator())
            {
                retval =
                    announcementsDAO.AddAnnouncement(announcement.ModuleID, announcement.ItemID,
                                                     announcement.CreatedByUser,
                                                     announcement.Title, announcement.ExpireDate.Value,
                                                     announcement.Description, announcement.MoreLink,
                                                     announcement.MobileMoreLink);
                transaction.Complete();
            }
            return retval;
        }
        //****************************************************************
        //
        // The UpdateBtn_Click event handler on this Page is used to either
        // create or update an announcement.  It  uses the Nairc.KPWPortal.AnnouncementsDB()
        // data component to encapsulate all data functionality.
        //
        //****************************************************************
        protected void UpdateBtn_Click(Object sender, EventArgs e)
        {
            // Only Update if the Entered Data is Valid
            if (Page.IsValid == true)
            {
                IDesktopModulesFacade facade = new DesktopModulesFacade();
                PortalAnnouncement announcement = new PortalAnnouncement();
                announcement.ModuleID =moduleId;
                announcement.ItemID =itemId;
                announcement.CreatedByUser =Context.User.Identity.Name;
                announcement.Title =TitleField.Text;
                announcement.ExpireDate =DateTime.Parse(ExpireField.Text);
                announcement.Description =DescriptionField.Text;
                announcement.MoreLink =MoreLinkField.Text;
                announcement.MobileMoreLink =MobileMoreField.Text;

                if (itemId == 0)
                {
                    // Add the announcement within the Announcements table
                    facade.AddAnnouncement(announcement);
                }
                else
                {
                    // Update the announcement within the Announcements table
                    facade.UpdateAnnouncement(announcement);
                }

                // Redirect back to the portal home page
                Response.Redirect((String) ViewState["UrlReferrer"]);
            }
        }