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; } }
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; } }
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; } }
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; } }
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; } }