Пример #1
0
        public void DeleteAll(Guid rootWidgetID)
        {
            IQueryable <carrot_WidgetData> w1 = CannedQueries.GetWidgetDataByRootAll(db, rootWidgetID);

            carrot_Widget w2 = CompiledQueries.cqGetRootWidget(db, rootWidgetID);

            bool bPendingDel = false;

            if (w1 != null)
            {
                db.carrot_WidgetDatas.BatchDelete(w1);
                bPendingDel = true;
            }

            if (w2 != null)
            {
                db.carrot_Widgets.DeleteOnSubmit(w2);
                bPendingDel = true;
            }

            if (bPendingDel)
            {
                db.SubmitChanges();
            }
        }
Пример #2
0
        public void Disable(Guid rootWidgetID)
        {
            carrot_Widget w = CompiledQueries.cqGetRootWidget(db, rootWidgetID);

            if (w != null)
            {
                w.WidgetActive = false;
                db.SubmitChanges();
            }
        }
Пример #3
0
        public void Save()
        {
            if (!this.IsWidgetPendingDelete) {

                SiteData site = new SiteData(CompiledQueries.cqGetSiteFromRootContentID(db, this.Root_ContentID));

                carrot_Widget w = CompiledQueries.cqGetRootWidget(db, this.Root_WidgetID);

                bool bAdd = false;
                if (w == null) {
                    bAdd = true;
                    w = new carrot_Widget();
                }

                if (this.Root_WidgetID == Guid.Empty) {
                    this.Root_WidgetID = Guid.NewGuid();
                }

                if (this.GoLiveDate.Year < 1900) {
                    this.GoLiveDate = site.Now.AddMinutes(-5);
                }
                if (this.RetireDate.Year < 1900) {
                    this.RetireDate = site.Now.AddYears(200);
                }

                w.Root_WidgetID = this.Root_WidgetID;

                w.WidgetOrder = this.WidgetOrder;
                w.Root_ContentID = this.Root_ContentID;
                w.PlaceholderName = this.PlaceholderName;
                w.ControlPath = this.ControlPath.Replace("~~/", "~/");
                w.WidgetActive = this.IsWidgetActive;
                w.GoLiveDate = site.ConvertSiteTimeToUTC(this.GoLiveDate);
                w.RetireDate = site.ConvertSiteTimeToUTC(this.RetireDate);

                carrot_WidgetData wd = new carrot_WidgetData();
                wd.Root_WidgetID = w.Root_WidgetID;
                wd.WidgetDataID = Guid.NewGuid();
                wd.IsLatestVersion = true;
                wd.ControlProperties = this.ControlProperties;
                wd.EditDate = DateTime.UtcNow;

                carrot_WidgetData oldWD = CompiledQueries.cqGetWidgetDataByRootID(db, this.Root_WidgetID);

                //only add a new entry if the widget has some sort of change in the data stored.
                if (oldWD != null) {
                    if (oldWD.ControlProperties != wd.ControlProperties) {
                        oldWD.IsLatestVersion = false;
                        db.carrot_WidgetDatas.InsertOnSubmit(wd);
                    }
                } else {
                    db.carrot_WidgetDatas.InsertOnSubmit(wd);
                }

                if (bAdd) {
                    db.carrot_Widgets.InsertOnSubmit(w);
                }

                db.SubmitChanges();

            } else {

                DeleteAll();

            }
        }
Пример #4
0
        public void Save()
        {
            if (!this.IsWidgetPendingDelete)
            {
                SiteData site = new SiteData(CompiledQueries.cqGetSiteFromRootContentID(db, this.Root_ContentID));

                carrot_Widget w = CompiledQueries.cqGetRootWidget(db, this.Root_WidgetID);

                bool bAdd = false;
                if (w == null)
                {
                    bAdd = true;
                    w    = new carrot_Widget();
                }

                if (this.Root_WidgetID == Guid.Empty)
                {
                    this.Root_WidgetID = Guid.NewGuid();
                }

                if (this.GoLiveDate.Year < 1900)
                {
                    this.GoLiveDate = site.Now.AddMinutes(-5);
                }
                if (this.RetireDate.Year < 1900)
                {
                    this.RetireDate = site.Now.AddYears(200);
                }

                w.Root_WidgetID = this.Root_WidgetID;

                w.WidgetOrder     = this.WidgetOrder;
                w.Root_ContentID  = this.Root_ContentID;
                w.PlaceholderName = this.PlaceholderName;
                w.ControlPath     = this.ControlPath.Replace("~~/", "~/");
                w.WidgetActive    = this.IsWidgetActive;
                w.GoLiveDate      = site.ConvertSiteTimeToUTC(this.GoLiveDate);
                w.RetireDate      = site.ConvertSiteTimeToUTC(this.RetireDate);

                carrot_WidgetData wd = new carrot_WidgetData();
                wd.Root_WidgetID     = w.Root_WidgetID;
                wd.WidgetDataID      = Guid.NewGuid();
                wd.IsLatestVersion   = true;
                wd.ControlProperties = this.ControlProperties;
                wd.EditDate          = DateTime.UtcNow;

                carrot_WidgetData oldWD = CompiledQueries.cqGetWidgetDataByRootID(db, this.Root_WidgetID);

                //only add a new entry if the widget has some sort of change in the data stored.
                if (oldWD != null)
                {
                    if (oldWD.ControlProperties != wd.ControlProperties)
                    {
                        oldWD.IsLatestVersion = false;
                        db.carrot_WidgetDatas.InsertOnSubmit(wd);
                    }
                }
                else
                {
                    db.carrot_WidgetDatas.InsertOnSubmit(wd);
                }

                if (bAdd)
                {
                    db.carrot_Widgets.InsertOnSubmit(w);
                }

                db.SubmitChanges();
            }
            else
            {
                DeleteAll();
            }
        }