Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }