예제 #1
0
        public Models.Category First(Models.CategorySearchModel conditions = null, string userName = null)
        {
            try
            {
                var entity = RestfulCategory.First(conditions);

                if (!CategoryAccessControl.Pass(RestfulAction.Read, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                return(entity);
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
        public bool Delete(int id, string userName)
        {
            try
            {
                var entity = RestfulCategory.Read(id);

                if (!CategoryAccessControl.Pass(RestfulAction.Delete, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                return(RestfulCategory.Delete(id));
            }
            catch
            {
                throw;
            }
        }
예제 #3
0
        public Models.Category Read(int id, string userName = null)
        {
            try
            {
                var entity = RestfulCategory.Read(id);

                if (!CategoryAccessControl.Pass(RestfulAction.Read, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                return(entity);
            }
            catch
            {
                throw;
            }
        }
예제 #4
0
        public Models.Category Create(Models.Category entity, string userName)
        {
            try
            {
                if (!CategoryAccessControl.Pass(RestfulAction.Create, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                entity.Creator = userName;
                entity.Created = DateTime.Now;

                return(RestfulCategory.Create(entity));
            }
            catch
            {
                throw;
            }
        }
예제 #5
0
        public Models.Category Update(int id, Models.Category entity, string userName)
        {
            try
            {
                var old = RestfulCategory.Read(id);

                if (!CategoryAccessControl.Pass(RestfulAction.Update, old, userName))
                {
                    throw new NoAccessException("No Access");
                }

                entity.Title   = old.Title;
                entity.Creator = userName;
                entity.Created = old.Created;
                entity.Updated = DateTime.Now;

                return(RestfulCategory.Update(id, entity));
            }
            catch
            {
                throw;
            }
        }