Ejemplo n.º 1
0
        public void SaveAndPublish()
        {
            var languageId = Language.CurrentLanguageId;

            using (var context = new DataContext())
            {
                var siteEntity = context.Sites.SingleOrDefault(x => x.SiteId == SiteId);

                if (siteEntity == null)
                {
                    siteEntity = new SiteEntity {
                        SiteId = SiteId
                    };

                    context.Add(siteEntity);
                    context.SaveChanges();
                }

                siteEntity.Author             = HttpContext.Current.User.Identity.Name;
                siteEntity.ChildSortDirection = ChildSortDirection;
                siteEntity.ChildSortOrder     = ChildSortOrder;
                siteEntity.Name       = Name;
                siteEntity.UpdateDate = DateTime.Now.ToUniversalTime();

                context.SaveChanges();

                // ---------------

                var propertiesForSite = context.SiteProperties.Where(x => x.SiteId == SiteId && x.LanguageId == languageId).ToList();

                foreach (var propertyItem in Property)
                {
                    var propertyEntity = propertiesForSite.Find(c => c.PropertyId == propertyItem.PropertyId);

                    if (propertyEntity == null)
                    {
                        propertyEntity = new SitePropertyEntity {
                            LanguageId = languageId,
                            SiteId     = SiteId,
                            PropertyId = propertyItem.PropertyId
                        };
                        context.Add(propertyEntity);
                        propertiesForSite.Add(propertyEntity);
                    }

                    propertyEntity.SiteData = GetSerializedPropertyValue(propertyItem);
                }

                context.SaveChanges();
            }

            SiteFactory.UpdateSite(this);
            CacheManager.RemoveRelated(SiteId);


            SiteFactory.RaiseSitePublished(SiteId, languageId);
        }
Ejemplo n.º 2
0
        public void SaveAndPublish() {
            var languageId = Language.CurrentLanguageId;

            using (var context = new DataContext())
            {
                var siteEntity = context.Sites.SingleOrDefault(x => x.SiteId == SiteId);

                if (siteEntity == null) {
                    siteEntity = new SiteEntity {
                        SiteId = SiteId
                    };

                    context.Add(siteEntity);
                    context.SaveChanges();
                }

                siteEntity.Author = HttpContext.Current.User.Identity.Name;
                siteEntity.ChildSortDirection = ChildSortDirection;
                siteEntity.ChildSortOrder = ChildSortOrder;
                siteEntity.Name = Name;
                siteEntity.UpdateDate = DateTime.Now.ToUniversalTime();

                context.SaveChanges();

                // ---------------

                var propertiesForSite = context.SiteProperties.Where(x => x.SiteId == SiteId && x.LanguageId == languageId).ToList();

                foreach (var propertyItem in Property) {
                    var propertyEntity = propertiesForSite.Find(c => c.PropertyId == propertyItem.PropertyId);

                    if (propertyEntity == null) {
                        propertyEntity = new SitePropertyEntity {
                            LanguageId = languageId,
                            SiteId = SiteId,
                            PropertyId = propertyItem.PropertyId
                        };
                        context.Add(propertyEntity);
                        propertiesForSite.Add(propertyEntity);
                    }

                    propertyEntity.SiteData = GetSerializedPropertyValue(propertyItem);
                }

                context.SaveChanges();
            }

            SiteFactory.UpdateSite(this);
            CacheManager.RemoveRelated(SiteId);


            SiteFactory.RaiseSitePublished(SiteId, languageId);
        }