//mapping Factory To Factory Full Data public async Task <FactoryDataModelWithFullData> MappingToFactoryFullDataAsync(Factory obj) { FactoryDataModelWithFullData MappedObj = new FactoryDataModelWithFullData() { FacId = obj.Id, Name = obj.Name, Scale = obj.Scale, businessType = obj.businessType, }; foreach (var item in obj.PrimarySources) { MappedObj.PrimarySources.Add(new PrimarySourceDataModel() { Id = item.Id, Code = item.Code, Name = item.Name, SourceLogs = await GetReadingsByIdAsync(item.Id), DesignValue = item.DesignValue, Type = item.Type, Topology = item.Topology, MaxCurrent = item.MaxCurrent }); } return(MappedObj); }
//GetFactoryWithFullData public async Task <FactoryDataModelWithFullData> GetFactoryWithDataByIdAsync(int Id) { FactoryDataModelWithFullData Result = new FactoryDataModelWithFullData(); var Query = _context.Factory.Include(f => f.PrimarySources).SingleOrDefault(f => f.Id == Id); if (Query != null) { Result = await MappingToFactoryFullDataAsync(Query); } return(Result); }