Example #1
0
        public IEnumerable <PersonNameType> Search([FromUri] PersonNameTypeCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var q    = db.PersonNameType;
                var list = (c == null ? q : q.Where(c.CreatePredicate())).ToList();
                return(list);
            }
        }
        public IActionResult PhysicallyRemove([FromQuery] PersonNameTypeCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var count = db.PersonNameType
                            .Where(c.CreatePredicate())
                            .Delete();
                return(Ok(count));
            }
        }
        public IActionResult Count([FromQuery] PersonNameTypeCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var count =
                    c == null?db.PersonNameType.Count() :
                        db.PersonNameType.Count(predicate: c.CreatePredicate());

                return(Ok(count));
            }
        }
Example #4
0
        public int Remove([FromUri] PersonNameTypeCondition c)
        {
#if DEBUG
            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine = (msg, context) => Debug.WriteLine(msg, context);
#endif
            using (var db = new peppaDB())
            {
                var count = db.PersonNameType
                            .Where(c.CreatePredicate())
                            .Set(_ => _.removed_at, Sql.CurrentTimestampUtc)
                            .Update();
                return(count);
            }
        }
        public IActionResult Search([FromQuery] PersonNameTypeCondition 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.PersonNameType
                        .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));
            }
        }