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