Example #1
0
        /// <summary>
        /// Deletes the record of the specified widget
        /// </summary>
        /// <param name="WidgetId">Id of the widget to be delted</param>
        /// <returns>Returns true if success and false on error</returns>
        public bool DeleteWidget(int WidgetId)
        {
            MediaManager mMgr = new MediaManager();

            data.Widget thisWidget = GetWidget(WidgetId);
            string      sql        = "Select MediaId From MediaWidgets Where WidgetId = {0}";

            if (thisWidget == null)
            {
                return(false);
            }

            int widgetId = thisWidget.Id;

            var d = DBUtils.GetDataSet(string.Format(sql, widgetId), cte.lib).Tables[0].Rows;

            int[] MediaIds = new int[d.Count];
            for (int i = 0; i < d.Count; i++)
            {
                MediaIds[i] = Int32.Parse(d[i]["MediaId"].ToString());
            }
            mMgr.DeleteMediaFromWidget(MediaIds, widgetId);

            WidgetsData.Widgets.DeleteOnSubmit(thisWidget);
            WidgetsData.SubmitChanges();

            return(true);
        }
Example #2
0
        /// <summary>
        /// Updates the widget based on the given params, params are nullable,
        /// if all were null no update shall occur.
        /// </summary>
        /// <param name="WidgetId">WidgetId, used to get the required widget</param>
        /// <param name="PageId">Id of the page to wich the widget is attached</param>
        /// <param name="Status">Status of the widget, 1/0 => true/false</param>
        /// <param name="Type">Type of the widget, we get it from the enum "DefaultWidgetsTypes" under Media project => enum.cs</param>
        /// <param name="Title">Title of the widget</param>
        /// <returns>true if success and false if widget not found</returns>
        public bool UpdateWidget(int WidgetId, int?PageId, bool?Status, int?Type, string Title)
        {
            data.Widget thisWidget = GetWidget(WidgetId);

            if (thisWidget == null)
            {
                return(false);
            }

            byte status = Status.GetValueOrDefault() ? (byte)1 : (byte)0;
            int  pageid = PageId.GetValueOrDefault();

            thisWidget.PageId       = pageid;
            thisWidget.Status       = status;
            thisWidget.Type         = Type;
            thisWidget.Title        = Title;
            thisWidget.ModifiedBy   = WebContext.Profile.UserId;
            thisWidget.DateModified = DateTime.Now;

            WidgetsData.SubmitChanges();
            return(true);
        }
Example #3
0
        /// <summary>
        /// Adds the widgets to the table having all needed parameters
        /// </summary>
        /// <param name="PageId">The Id of the Page to which the widget will be related</param>
        /// <param name="Status">Status of the widget (1=>true, 0=>false) with DB type bit/tinyint</param>
        /// <param name="Type">Type of widget, we get it from the enum "DefaultWidgetsTypes" under Media project => enum.cs</param>
        /// <param name="Title">Title of the widget</param>
        /// <param name="CreatedBy">CreatorId of the creator of the widget</param>
        /// <param name="ModifiedBy">CreatorId of the modifier of the widget</param>
        /// <returns></returns>
        public data.Widget AddWidget(int?PageId, bool?Status, int Type, string Title, int CreatedBy, int ModifiedBy, DateTime?ExpiratinDate)
        {
            byte status = Status.GetValueOrDefault() ? (byte)1 : (byte)0;
            int  pageid = PageId.GetValueOrDefault();

            data.Widget widget = new data.Widget
            {
                PageId         = pageid,
                Status         = status,
                Type           = Type,
                Title          = Title,
                DateAdded      = DateTime.Now,
                DateModified   = DateTime.Now,
                ExpirationDate = ExpiratinDate,
                CreatedBy      = CreatedBy,
                ModifiedBy     = ModifiedBy
            };

            WidgetsData.Widgets.InsertOnSubmit(widget);
            WidgetsData.SubmitChanges();

            return(widget);
        }