public Tuple <IEnumerable <GradePhyRecord>, int> GetRecords(QueryGradeRecordViewModel model) { if (model == null) { return(null); } var result = _context.GradePhyRecords.AsQueryable(); if (model.CreateBy.Valid()) { result = result.Where(r => r.CreateById == model.CreateBy.Value); } if (model.CreateFor.Valid()) { result = result.Where(r => r.UserId == model.CreateFor.Value); } if (!model.Create.Valid()) { model.Create = new QueryByDate() { Start = DateTime.Now.AddYears(-1), End = DateTime.Now } } ; result = result.Where(r => r.Create >= model.Create.Start).Where(r => r.Create <= model.Create.End); var list = result.SplitPage(model.Pages.ValidSplitPage()); return(new Tuple <IEnumerable <GradePhyRecord>, int>(list.Item1.ToList(), list.Item2)); } }
public IActionResult GetGrade([FromBody] QueryGradeRecordViewModel model) { var result = phyGradeServices.GetRecords(model); return(new JsonResult(new EntitiesListViewModel <GradePhyRecord>(result?.Item1, result?.Item2 ?? -1))); }