Exemplo n.º 1
0
        public IEnumerable <InspectionDetailViewModel> Get(string objectI, string truckC)
        {
            var data = from a in _inspectionDetailRepository.GetAllQueryable()
                       join b in _inspectionRepository.GetAllQueryable() on a.InspectionC equals b.InspectionC
                       where (a.ObjectI == objectI && a.Code == truckC)
                       select new InspectionDetailViewModel()
            {
                ObjectI         = a.ObjectI,
                Code            = a.Code,
                InspectionC     = a.InspectionC,
                InspectionN     = b.InspectionN,
                InspectionD     = a.InspectionD,
                InspectionPlanD = a.InspectionPlanD,
                Odometer        = a.Odometer,
                Description     = a.Description
            };
            var dataMaintenance = from a in _inspectionDetailRepository.GetAllQueryable()
                                  where (a.ObjectI == objectI && a.Code == truckC && a.InspectionC == 0)
                                  select new InspectionDetailViewModel()
            {
                ObjectI         = a.ObjectI,
                Code            = a.Code,
                InspectionC     = a.InspectionC,
                InspectionN     = "",
                InspectionD     = a.InspectionD,
                InspectionPlanD = a.InspectionPlanD,
                Odometer        = a.Odometer,
                Description     = a.Description
            };

            if (dataMaintenance.Any())
            {
                data = data.Concat(dataMaintenance);
            }

            if (data.Any())
            {
                return(data.ToList().OrderBy(x => x.InspectionPlanD).ThenBy(x => x.InspectionD));
            }
            return(null);
        }