public IActionResult PhysicallyRemove([FromQuery] TeacherLisenceTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = db.TeacherLisenceType .Where(c.CreatePredicate()) .Delete(); return(Ok(count)); } }
public IActionResult Count([FromQuery] TeacherLisenceTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = c == null?db.TeacherLisenceType.Count() : db.TeacherLisenceType.Count(predicate: c.CreatePredicate()); return(Ok(count)); } }
public IActionResult Remove([FromQuery] TeacherLisenceTypeCondition c) { #if DEBUG DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context); #endif using (var db = new peppaDB()) { var count = db.TeacherLisenceType .Where(c.CreatePredicate()) .Set(_ => _.modified_by, CurrentAccountId) .Set(_ => _.removed_at, Sql.CurrentTimestampUtc) .Update(); return(Ok(count)); } }
public IActionResult Search([FromQuery] TeacherLisenceTypeCondition 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.TeacherLisenceType .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)); } }