public ActionResult GetAll(int pageSize = 20, int pageIndex = 1, string query = "", bool?standard = null) { IEnumerable <EnglishWord> items = this._unitOfWork.EnglishWords.GetAll(); if (!string.IsNullOrEmpty(query)) { items = items.Where(i => i.Word.ToLower().Contains(query.ToLower())); } if (standard == true) { items = items.Where(i => i.Standard == true); } var count = items.Count(); IEnumerable <EnglishWord> subset; if (pageSize > 0) { subset = items .OrderBy(i => i.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); } else { subset = items .OrderBy(i => i.Word); } var R = PageRecordsSelector.GetPageRecords(subset, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetAll(int pageSize = 20, int pageIndex = 1, string query = "", int?levelId = null, int?categoryId = null, int?formId = null) { IEnumerable <SekaniRoot> items = this._unitOfWork.SekaniRoots.GetAll(); if (!string.IsNullOrEmpty(query)) { items = items.Where(i => i.RootWord.ToLower().Contains(query.ToLower())); } if (levelId != null && levelId != 0) { items = items.Where(i => i.SekaniLevelId == levelId); } if (categoryId != null && categoryId != 0) { items = items.Where(i => i.SekaniCategoryId == categoryId); } if (formId != null && formId != 0) { items = items.Where(i => i.SekaniFormId == formId); } var count = items.Count(); IEnumerable <SekaniRoot> subset; if (pageSize > 0) { subset = items .OrderBy(i => i.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); } else { subset = items .OrderBy(i => i.Id); } var _items = subset .Select(item => new { item.Id, item.IsNull, item.RootWord, item.SekaniCategoryId, item.SekaniFormId, item.SekaniLevelId, item.UpdateTime, Level = pageSize > 0 ? _unitOfWork.SekaniLevels.Get(item.SekaniLevelId).Title : null, Category = pageSize > 0 ? _unitOfWork.SekaniCategories.Get(item.SekaniCategoryId).Title: null, Form = pageSize > 0 ? _unitOfWork.SekaniForms.Get(item.SekaniFormId).Title: null }); var R = PageRecordsSelector.GetPageRecords(_items, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetAll(int pageSize = 20, int pageIndex = 1, int sekaniWordId = 0) { var items = this._unitOfWork.SekaniWordExamples.GetAll().Where(i => i.SekaniWordId == sekaniWordId); var count = items.Count(); var subset = items .OrderBy(i => i.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); var R = PageRecordsSelector.GetPageRecords(subset, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetAll(int pageSize = 20, int pageIndex = 1) { IEnumerable <Topic> items = this._unitOfWork.Topics.GetAll(); var count = items.Count(); IEnumerable <Topic> subset; subset = this._unitOfWork.Topics.GetAll() .OrderBy(i => i.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); var R = PageRecordsSelector.GetPageRecords(subset, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetSessions(int pageSize = 20, int pageIndex = 1) { var items = this._unitOfWork.PersistedGrants.GetAll() .GroupBy(i => i.SubjectId) .Select(i => new { Username = this._unitOfWork.Users.GetAll().Where(u => u.Id == int.Parse(i.FirstOrDefault().SubjectId)).FirstOrDefault().Username, Count = i.Count() }); var count = items.Count(); var records = items.OrderBy(i => i.Username) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); var R = PageRecordsSelector.GetPageRecords(records, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetFailedWords(int pageSize = 20, int pageIndex = 1) { int userId = UserHelper.GetCurrentUserId(User); var items = _unitOfWork.UserFailedWords.Find(x => x.UserId == userId); var count = items.Count(); var records = items .OrderBy(s => s.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize) .Select(x => new { x.Id, x.SekaniWordId, x.UserId, SekaniWord = _unitOfWork.SekaniWords.Find(i => i.Id == x.Id).Select(i => i.Word), x.UpdateTime }); var R = PageRecordsSelector.GetPageRecords(records, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetAll(int pageSize = 20, int pageIndex = 1) { var items = _unitOfWork.Users.GetAll(); var count = items.Count(); var records = items .OrderBy(s => s.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize) .Select(x => new { x.Id, x.FirstName, x.LastName, x.Email, x.PhoneNumber, x.DateOfBirth, x.Active, x.EmailVerified }); var R = PageRecordsSelector.GetPageRecords(records, pageSize, pageIndex, count); return(Ok(R)); }
public ActionResult GetAll(int pageSize = 20, int pageIndex = 1, int?sekaniRootId = 0) { IEnumerable <SekaniWord> items = this._unitOfWork.SekaniWords.GetAll(); if (sekaniRootId != null && sekaniRootId != 0) { items = items.Where(i => i.SekaniRootId == sekaniRootId); } var count = items.Count(); IEnumerable <SekaniWord> subset = items .OrderBy(i => i.Id) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); var _items = subset.Select(i => new { i.Id, i.Phonetic, i.SekaniRootId, i.UpdateTime, i.Word, Attributes = this._unitOfWork.SekaniWordAttributes.Find(a => a.SekaniWordId == i.Id).Select(a => new { a.Id, a.Key, a.Value, a.UpdateTime }) }); var R = PageRecordsSelector.GetPageRecords(_items, pageSize, pageIndex, count); return(Ok(R)); }