Example #1
0
        public async Task <InspectionByIdDto> InspectionByIdForEventTable(int inspectionId)
        {
            var sqlRInspection = new InspectionRepository(_logger);
            var inspectionDto  = await sqlRInspection.ByIdForEventTable(inspectionId);

            var sqlRTrainTaskAttributes = new TrainTaskAttributesRepository(_logger);

            if (inspectionDto == null)
            {
                throw new NotFoundException();
            }
            inspectionDto.Id = "M" + inspectionDto.InspectionId;

            inspectionDto.Type        = GetStringInspectionType((CheckListType)inspectionDto.TypeInt);
            inspectionDto.Status      = GetStringInspectionStatus((InspectionStatus)inspectionDto.StatusInt);
            inspectionDto.BrigadeName = GetStringBrigadeType((BrigadeType)inspectionDto.BrigadeTypeInt);

            var endDateString = string.Empty;

            if (inspectionDto.DateEnd.HasValue)
            {
                endDateString = $" - {inspectionDto.DateEnd:g}";
            }
            inspectionDto.Date = $"{inspectionDto.DateStart:g}" + endDateString;


            //TaskCount
            var taskAttributesByInspectionCount = await sqlRTrainTaskAttributes.ByInspectionId(inspectionId);

            inspectionDto.TaskCount = taskAttributesByInspectionCount.Count;

            //Метки
            inspectionDto.Labels = await GetInspectionLabels(inspectionId);

            //Счетчики киловат и прочей хери
            inspectionDto.InspectionDataCarriages = await GetInspectionCounters(inspectionId);

            //Остальные данные по инспекции
            inspectionDto.InspectionDataUis = await GetInspectionOtherData(inspectionId);

            return(inspectionDto);
        }