コード例 #1
0
ファイル: Comment.cs プロジェクト: cymbidum/HITRating
        public Models.Comment First(Models.CommentSearchModel conditions = null, string userName = null)
        {
            try
            {
                var entity = RestfulComment.First(conditions);

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

                return(entity);
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
ファイル: Comment.cs プロジェクト: cymbidum/HITRating
        public bool Delete(int id, string userName)
        {
            try
            {
                var entity = RestfulComment.Read(id);

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

                return(RestfulComment.Delete(id));
            }
            catch
            {
                throw;
            }
        }
コード例 #3
0
ファイル: Comment.cs プロジェクト: cymbidum/HITRating
        public Models.Comment Read(int id, string userName = null)
        {
            try
            {
                var entity = RestfulComment.Read(id);

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

                return(entity);
            }
            catch
            {
                throw;
            }
        }
コード例 #4
0
ファイル: Comment.cs プロジェクト: cymbidum/HITRating
        public Models.Comment Create(Models.Comment entity, string userName)
        {
            try
            {
                if (!CommentAccessControl.Pass(RestfulAction.Create, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

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

                return(RestfulComment.Create(entity));
            }
            catch
            {
                throw;
            }
        }
コード例 #5
0
ファイル: Comment.cs プロジェクト: cymbidum/HITRating
        public Models.Comment Update(int id, Models.Comment entity, string userName)
        {
            try
            {
                var old = RestfulComment.Read(id);

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

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

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