예제 #1
0
        public async Task <IActionResult> GetInspections([FromQuery] UserParams userParams)
        {
            var inspections = await _repo.GetInspectionMs(userParams);

            var inspectionsToReturn = _mapper.Map <IEnumerable <InspectionForListDto> >(inspections);

            Response.AddPagination(inspections.CurrentPage, inspections.PageSize,
                                   inspections.TotalCount, inspections.TotalPages);

            if (inspectionsToReturn.Count() == 0)
            {
                return(BadRequest("Unit " + userParams.UnitId + " could not be found"));
            }

            return(Ok(inspectionsToReturn));

            //var inspection = _context.InspectionsM.AsQueryable();

            ////if (String.IsNullOrEmpty(userParams.UnitId))
            //    return BadRequest("Provide Parameter String");

            //inspection = inspection.Where(i => i.ImEquip1Id.Equals(userParams.UnitId));

            //inspection = inspection.Include(i => i.BillToClient);
            //inspection = inspection.Include(i => i.InspectionD);
            //inspection = inspection.Include(g => g.Depot);
            //inspection = inspection.Include(g => g.EquipmentType);

            //inspection = inspection.OrderByDescending(i => i.ImInspectionDate);

            //var response = await inspection.ToListAsync();

            //var inspectiond = _context.InspectionsD.AsQueryable();

            //inspectiond = inspectiond.Where(i => i.IdInspectionRefNmbr.Equals(response[0].ImInspectionRefNmbr));

            //inspectiond = inspectiond.OrderBy(i => i.IdLineNmbr);

            //var responsed = await inspectiond.ToListAsync();

            //response[0].InspectionD = responsed;

            //if (response.Count == 0)
            //   return BadRequest("Unit " + userParams.UnitId + " could not be found" );

            //return Ok(response);
        }