Ejemplo n.º 1
0
        public SaveResult SaveProductCategory( ProductCategoryModel model )
        {
            ContentManagementDb db = new ContentManagementDb();

            ProductCategory productCategory = db.ProductCategories.Find( model.ProductCategoryId );

            if ( productCategory == null )
            {
                return CreateProductCategory( model, db );
            }

            return UpdateProductCategory( productCategory, model, db );
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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;
            }
        }