Example #1
0
        protected void saveCallBack_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
        {
            JsonSerializer serializer = new JsonSerializer();

            StringReader reader = new StringReader(e.Parameter);
            using (JsonReader jsonReader = new JsonTextReader(reader))
            {
                List<GroupJSON> p = (List<GroupJSON>)serializer.Deserialize(jsonReader, typeof(List<GroupJSON>));
                if (p != null)
                {
                    bool isManagerSet = false;
                    BusinessLogicLayer.Entities.ContentManagement.SitePageManager manager = null;
                    foreach (GroupJSON group in p)
                    {
                        if (group.IsDeleted)
                            BusinessLogicLayer.Common.HomePageGroupLogic.Delete(group.ID);
                        else
                        {
                            if (!isManagerSet)
                            {
                                manager = new BusinessLogicLayer.Components.ContentManagement.SitePageManagerLogic().GetBySectionandType(group.SectionID, Convert.ToInt32(cmbPageType.Value));

                                if (manager == null)
                                {
                                    manager = new BusinessLogicLayer.Entities.ContentManagement.SitePageManager();
                                    manager.SectionID = group.SectionID;
                                    manager.SitePageTypeID = group.PageType;
                                }
                                manager.IsMain = group.IsMain;
                                if (manager.NewRecord)
                                    new BusinessLogicLayer.Components.ContentManagement.SitePageManagerLogic().Insert(manager);
                                else
                                    new BusinessLogicLayer.Components.ContentManagement.SitePageManagerLogic().Update(manager, manager.SitePageManagerID);
                                isManagerSet = true;
                            }
                            BusinessLogicLayer.Entities.ContentManagement.HomePageGroup hgroup = new BusinessLogicLayer.Entities.ContentManagement.HomePageGroup();
                            hgroup.GroupClass = group.GroupClass;
                            hgroup.GroupName = group.Name;
                            hgroup.SitePageManagerID = manager.SitePageManagerID;
                            hgroup.HomePageGroupID = group.ID;
                            hgroup.NewRecord = !group.OldGroup;
                            hgroup.SectionID = group.SectionID;
                            hgroup.SitePageLayoutID = group.LayoutID;
                            hgroup.OrderNumber = group.OrderNumber;
                            if (hgroup.NewRecord)
                            {
                                BusinessLogicLayer.Common.HomePageGroupLogic.Insert(hgroup);
                            }
                            else
                            {
                                BusinessLogicLayer.Common.HomePageGroupLogic.Update(hgroup, hgroup.HomePageGroupID);
                            }
                            string ids = "";
                            foreach (WidgetJSON widget in group.Widgets)
                            {

                                if (widget.IsDeleted)
                                    BusinessLogicLayer.Common.HomePageLogic.Delete(widget.ID);
                                else
                                {
                                    BusinessLogicLayer.Entities.ContentManagement.HomePage homePage = new BusinessLogicLayer.Entities.ContentManagement.HomePage();
                                    homePage.ContentModuleTypeID = widget.ContentModuleTypeID;
                                    homePage.HomePageGroupID = hgroup.HomePageGroupID;
                                    homePage.HomePageID = widget.ID;
                                    homePage.IsActive = widget.IsActive;
                                    homePage.IsFullWidth = widget.IsFullWidth;
                                    homePage.ItemsNumber = widget.ItemsNumber;

                                    homePage.ItemsPerPage = widget.ItemsPerPage;
                                    homePage.LanguageID = widget.LanguageID;
                                    homePage.OrderNumber = widget.OrderNumber;
                                    homePage.PositionID = widget.PositionID;
                                    homePage.SectionID = Convert.ToInt32(cmbSection.Value);
                                    homePage.SiteID = Convert.ToInt32(cmbSite.Value);
                                    homePage.NewRecord = !widget.OldGroup;
                                    homePage.Title = widget.Name;
                                    if (homePage.NewRecord)
                                        BusinessLogicLayer.Common.HomePageLogic.Insert(homePage);
                                    else
                                        BusinessLogicLayer.Common.HomePageLogic.Update(homePage, homePage.HomePageID);
                                    ids += homePage.HomePageID + ",";
                                }
                            }
                            if(ids.Length > 0)
                            {
                                    ids = ids.Remove(ids.Length - 1,1);
                                    BusinessLogicLayer.Common.HomePageLogic.Delete(ids, hgroup.HomePageGroupID);
                            }
                        }

                    }
                }
            }
        }
Example #2
0
        public void LoadData()
        {
            if (!IsPostBack)
            {
                if (HomePageID == 0) return;
                HomePage = HomePageLogic.GetByID(HomePageID);

                Articles = new BusinessLogicLayer.Components.ContentManagement.ContentModuleArticleLogic().GetAllByHomePageIDOrdered(HomePageID);
                int i = Articles.Count;
                if (i < HomePage.ItemsNumber)
                {
                    ModuleSections = ModuleSectionLogic.GetAllByHomePageID(HomePageID);
                    foreach (BusinessLogicLayer.Entities.ContentManagement.ModuleSection moduleSection in ModuleSections)
                    {
                        if (i >= HomePage.ItemsNumber) break;
                        foreach (BusinessLogicLayer.Entities.ContentManagement.Article article in moduleSection.Articles)
                        {
                            if (i >= HomePage.ItemsNumber) break;
                            BusinessLogicLayer.Entities.ContentManagement.ContentModuleArticle cmArticles = new BusinessLogicLayer.Entities.ContentManagement.ContentModuleArticle();
                            cmArticles.ArticleID = article.ArticleId;
                            cmArticles.CurrentArticle = article;
                            cmArticles.ArticleOrder = i;
                            cmArticles.HomePageID = HomePageID;
                            Articles.Add(cmArticles);
                            i++;
                        }

                    }
                }
                ItemCount = HomePage.ItemsNumber;
            }
        }
Example #3
0
 public ListItemsControl(List<BusinessLogicLayer.Entities.ContentManagement.Article> articles, BusinessLogicLayer.Entities.ContentManagement.HomePage homePage)
 {
     Articles = articles;
     HomePage = homePage;
 }