public IEnumerable <RolePermission> Search([FromUri] RolePermissionCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var q = db.RolePermission; var list = (c == null ? q : q.Where(c.CreatePredicate())).ToList(); return(list); } }
public IActionResult Remove([FromQuery] RolePermissionCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = db.RolePermission .Where(c.CreatePredicate()) .Delete(); return(Ok(count)); } }
public IActionResult Count([FromQuery] RolePermissionCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = c == null?db.RolePermission.Count() : db.RolePermission.Count(predicate: c.CreatePredicate()); return(Ok(count)); } }
public IActionResult Search([FromQuery] RolePermissionCondition c, [FromQuery] string[] order, int currentPage = 1, int pageSize = 10, DateTime?p_when = null) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var q = db.RolePermission .IsActiveAt(p_when) ; var filtered = c == null ? q : q.Where(c.CreatePredicate()); var ordered = order.Any() ? filtered.SortBy(order) : filtered; var result = ordered.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList(); return(Ok(result)); } }