AngularTutorial.Controllers.TodoController.GetTodos C# (CSharp) Method

GetTodos() public method

public GetTodos ( string q = null, string sort = null, bool desc = false, int limit = null, int offset ) : IEnumerable
q string
sort string
desc bool
limit int
offset int
return IEnumerable
        public IEnumerable<Todo> GetTodos(string q = null, string sort = null, bool desc = false,
                                                               int? limit = null, int offset = 0)
        {
            var list = ((IObjectContextAdapter) db).ObjectContext.CreateObjectSet<Todo>();

            IQueryable<Todo> items = string.IsNullOrEmpty(sort)
                ? list.OrderBy(o=>o.Priority)
                : list.OrderBy(String.Format("it.{0} {1}", sort, desc ? "DESC" : "ASC"));

            if (!string.IsNullOrEmpty(q) && q != "undefined")
                items = items.Where(t => t.Text.Contains(q));

            if (offset > 0) items = items.Skip(offset);
            if (limit.HasValue) items = items.Take(limit.Value);
            return items;
        }