public async Task <ActionResult> Get([FromQuery] string keyword, [FromQuery] AbsensiFilter filter, [FromQuery] int page = 1, [FromQuery] int size = 25) { try { VerifyUser(); //var query = _AbsensiService.GetQuery(); //if (!string.IsNullOrWhiteSpace(keyword)) // query = query.Where(entity => entity.Code.Contains(keyword) || entity.Name.Contains(keyword)); /*var queryResult = await query * .Skip((page - 1) * size) * .Take(size) * .OrderByDescending(entity => entity.LastModifiedUtc) * .ToListAsync(); * * var result = new ResultFormatter(API_VERSION, General.OK_STATUS_CODE, General.OK_MESSAGE) * .Ok(queryResult); * return Ok(result); */ var query = _AbsensiService.Find(filter); return(Ok(query)); } catch (Exception e) { var result = new ResultFormatter(API_VERSION, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, result)); } }
public IEnumerable <Absensi> Find(AbsensiFilter filter) { IQueryable <Absensi> query = _employeeContext.Absensi; if (filter.Ids.Any()) { query = query.Where(o => filter.Ids.Contains(o.id_absensi)); } if (!string.IsNullOrEmpty(filter.Username)) { query = query.Where(o => o.Username.Contains(filter.Username)); } if (!string.IsNullOrEmpty(filter.Keterangan)) { query = query.Where(o => o.Keterangan.Contains(filter.Keterangan)); } /*if (!string.IsNullOrEmpty(filter.State)) * query = query.Where(o => o.State.Contains(filter.State)); * * if (!string.IsNullOrEmpty(filter.CheckIn)) * query = query.Where(o => o.CheckIn.ToString().Contains(filter.CheckIn)); * * if (!string.IsNullOrEmpty(filter.Approval)) * query = query.Where(o => o.Approval.Contains(filter.Approval)); * * if (!string.IsNullOrEmpty(filter.HeadDivision)) * query = query.Where(o => o.HeadDivision.Contains(filter.HeadDivision)); * * if (!string.IsNullOrEmpty(filter.ApprovalByAdmin)) * query = query.Where(o => o.ApprovalByAdmin.Contains(filter.ApprovalByAdmin));*/ /* if (filter.SortByUsername.HasValue && filter.SortByUsername.Value == SortByAtOffice.ASC) * query = query.OrderBy(o => o.Username); * * if (filter.SortByUsername.HasValue && filter.SortByUsername.Value == SortByAtOffice.DESC) * query = query.OrderByDescending(o => o.Username);*/ /* if (filter.SortByDate.HasValue && filter.SortByDate.Value == SortByAtOffice.ASC) * query = query.OrderBy(o => o.CheckIn); * * if (filter.SortByDate.HasValue && filter.SortByDate.Value == SortByAtOffice.DESC) * query = query.OrderByDescending(o => o.CheckIn);*/ return(query.ToList()); }
public IActionResult Get([FromQuery] AbsensiFilter filter) { IEnumerable <Absensi> employees = _dataRepository.Find(filter); return(Ok(employees)); }
public IEnumerable <Absensi> Find(AbsensiFilter filter) { IQueryable <Absensi> query = _dbContext.Absensis; if (filter.Ids.Any()) { query = query.Where(o => filter.Ids.Contains(o.Id)); } if (!string.IsNullOrEmpty(filter.Name)) { query = query.Where(o => o.Name.Contains(filter.Name)); } if (!string.IsNullOrEmpty(filter.Username)) { query = query.Where(o => o.Username.Contains(filter.Username)); } if (!string.IsNullOrEmpty(filter.State)) { query = query.Where(o => o.State.Contains(filter.State)); } if (!string.IsNullOrEmpty(filter.NotState)) { query = query.Where(o => !o.State.Contains(filter.NotState)); } if (!string.IsNullOrEmpty(filter.CheckIn)) { query = query.Where(o => o.CheckIn.ToString().Contains(filter.CheckIn)); } if (!string.IsNullOrEmpty(filter.Approval)) { query = query.Where(o => o.Approval.Contains(filter.Approval)); } if (!string.IsNullOrEmpty(filter.HeadDivision)) { query = query.Where(o => o.HeadDivision.Contains(filter.HeadDivision)); } if (!string.IsNullOrEmpty(filter.ApprovalByAdmin)) { query = query.Where(o => o.ApprovalByAdmin.Contains(filter.ApprovalByAdmin)); } if (filter.SortByUsername.HasValue && filter.SortByUsername.Value == SortBy.ASC) { query = query.OrderBy(o => o.Username); } if (filter.SortByUsername.HasValue && filter.SortByUsername.Value == SortBy.DESC) { query = query.OrderByDescending(o => o.Username); } if (filter.SortByDate.HasValue && filter.SortByDate.Value == SortBy.ASC) { query = query.OrderBy(o => o.CheckIn); } if (filter.SortByDate.HasValue && filter.SortByDate.Value == SortBy.DESC) { query = query.OrderByDescending(o => o.CheckIn); } return(query.ToList()); }