public IActionResult gets( [FromQuery] string keyword, [FromQuery] int limit = 100, [FromQuery] int offset = 0, [FromQuery] bool count = false ) { int totalRecord = 0; try { // General Where query Expression <Func <user, bool> > where = x => x.isdeleted == false; // Check keyword if (!(string.IsNullOrEmpty(keyword))) { var compiled = where.Compile(); where = x => compiled(x) && x.name.ToLower().Contains(keyword.ToLower()); } // Includes // Count if (count) { totalRecord = _userService.Count(where); } resultDTO <user> res = new resultDTO <user>() { result = _userService.getUsers(where, limit, offset, count), count = totalRecord }; return(Ok(res)); } catch (serviceException e) { return(BadRequest(e.ToString())); } catch (AuthenticationException) { return(Forbid()); } catch (Exception e) { return(BadRequest(e.ToString())); } }
public IActionResult gets( [FromQuery] string keyword, [FromQuery] int offset = 0, [FromQuery] int limit = 100, [FromQuery] bool count = false ) { int generalCount = 0; try { Expression <Func <project, bool> > where = x => x.isdeleted == false; if (!(string.IsNullOrEmpty(keyword))) { var compiled = where.Compile(); where = x => compiled(x) && x.name.ToLower().Contains(keyword.ToLower()); } if (count == true) { generalCount = _projectService.Count(where); } resultDTO <project> res = new resultDTO <project>() { result = _projectService.gets(where, offset, limit, count), count = generalCount }; return(Ok(res)); } catch (serviceException e) { return(BadRequest(e.ToString())); } catch (AuthenticationException) { return(Forbid()); } catch (Exception e) { return(BadRequest(e.ToString())); } }