コード例 #1
0
ファイル: PageManager.cs プロジェクト: demonwithin01/bg-cms
        private SaveResult CreatePage( PageModel model, ContentManagementDb db )
        {
            try
            {
                Page page = new Page();
                page.Initialise();

                AutoMap.Map( model, page );

                page.CreatedByUserId = UserSession.Current.UserId;
                page.DomainId = UserSession.Current.DomainId;

                PageContent pageContent = new PageContent();

                AutoMap.Map( model, pageContent );
                page.PageContent.Add( pageContent );

                pageContent.Initialize();

                pageContent.LastEditedByUserId = page.CreatedByUserId;

                SetPublishStatus( page, pageContent, model.Publish );

                db.Pages.Add( page );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch
            {
                return SaveResult.Fail;
            }
        }
コード例 #2
0
ファイル: BlogManager.cs プロジェクト: demonwithin01/bg-cms
        private SaveResult CreateBlog( BlogPostModel model, ContentManagementDb db )
        {
            try
            {
                Blog blog = new Blog();
                blog.Initialise();

                AutoMap.Map( model, blog );

                blog.CreatedByUserId = UserSession.Current.UserId;
                blog.DomainId = UserSession.Current.DomainId;

                BlogContent blogContent = new BlogContent();

                AutoMap.Map( model, blogContent );
                blog.BlogContent.Add( blogContent );

                blogContent.Initialize();

                blogContent.LastEditedByUserId = blog.CreatedByUserId;

                SetPublishStatus( blog, blogContent, model.Publish );

                db.Blogs.Add( blog );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch
            {
                return SaveResult.Fail;
            }
        }
コード例 #3
0
        private SaveResult UpdateNavItem( DomainNavigationItem navItem, NavigationModel model, ContentManagementDb db )
        {
            if ( UserSession.Current.IsAdministrator == false ) return SaveResult.AccessDenied;

            if ( UserSession.Current.CurrentDomain( db ).CanAccess( navItem ) == false ) return SaveResult.IncorrectDomain;

            try
            {
                AutoMap.Map( model, navItem );
                navItem.UpdateTimeStamp();

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch
            {
                return SaveResult.Fail;
            }
        }
コード例 #4
0
        private SaveResult UpdateProductCategory( ProductCategory product, ProductCategoryModel model, ContentManagementDb db )
        {
            if ( UserSession.Current.IsAdministrator == false )
                return SaveResult.AccessDenied;

            if ( UserSession.Current.CurrentDomain( db ).CanAccess( product ) == false )
                return SaveResult.IncorrectDomain;

            try
            {
                AutoMap.Map( model, product );
                product.UpdateTimeStamp();

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch
            {
                return SaveResult.Fail;
            }
        }
コード例 #5
0
        private SaveResult CreateProductCategory( ProductCategoryModel model, ContentManagementDb db )
        {
            try
            {
                ProductCategory productCategory = new ProductCategory();
                productCategory.Initialise();

                AutoMap.Map( model, productCategory );

                productCategory.DomainId = UserSession.Current.DomainId;

                db.ProductCategories.Add( productCategory );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch// (Exception ex)
            {
                return SaveResult.Fail;
            }
        }
コード例 #6
0
        private SaveResult CreateNavItem( NavigationModel model, ContentManagementDb db )
        {
            try
            {
                DomainNavigationItem navItem = new DomainNavigationItem();
                navItem.Initialise();

                AutoMap.Map( model, navItem );

                navItem.DomainId = UserSession.Current.DomainId;

                db.DomainNavigationItems.Add( navItem );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch
            {
                return SaveResult.Fail;
            }
        }
コード例 #7
0
        private SaveResult CreateProduct( ProductModel model, ContentManagementDb db )
        {
            try
            {
                Product product = db.Products.Create();
                product.Initialise();

                AutoMap.Map( model, product );

                product.DomainId = UserSession.Current.DomainId;

                db.Products.Add( product );

                UpdateProductImages( product, model );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch// ( Exception ex )
            {
                return SaveResult.Fail;
            }
        }
コード例 #8
0
ファイル: PageManager.cs プロジェクト: demonwithin01/bg-cms
        private SaveResult UpdatePage( Page page, PageModel model, ContentManagementDb db )
        {
            if ( UserSession.Current.IsAdministrator == false ) return SaveResult.AccessDenied;

            if ( UserSession.Current.CurrentDomain( db ).CanAccess( page ) == false ) return SaveResult.IncorrectDomain;

            try
            {
                PageContent pageContent = page.PageContent.FirstOrDefault( s => s.PublishStatus == PublishStatus.Draft );

                if ( pageContent == null )
                {
                    pageContent = new PageContent();
                    page.PageContent.Add( pageContent );
                }

                AutoMap.Map( model, pageContent );
                page.UpdateTimeStamp();
                pageContent.UpdateTimeStamp();
                pageContent.LastEditedByUserId = UserSession.Current.UserId;

                SetPublishStatus( page, pageContent, model.Publish );

                db.SaveChanges();

                return SaveResult.Success;
            }
            catch
            {
                return SaveResult.Fail;
            }
        }