public IList <DataSourceDto> GetLanguagesDataSource() { IList <DataSourceDto> dataSource = new List <DataSourceDto>(); foreach (ProgrammingLanguage result in Enum.GetValues(typeof(ProgrammingLanguage))) { var newDataItem = new DataSourceDto() { ID = (int)result, Name = result.ToString() }; if (result == ProgrammingLanguage.CSharp) { newDataItem.Name = C_SHARP_LANGUAGE_TEXT; } else if (result == ProgrammingLanguage.CPlusPlus) { newDataItem.Name = C_PLUS_PLUS_LANGUAGE_TEXT; } dataSource.Add(newDataItem); } return(dataSource); }
private void CreateAttributes(DataSourceDto dto) { this.name = dto.Name; Writer.Seek(0, SeekOrigin.End); this.fixup.FixupPosition = Writer.BaseStream.Position; Writer.Write(dto.ConversionFunction); Writer.Write(Convert.ToInt32(dto.PollingInterval.TotalSeconds)); if (this.lastReadingDao == null) { this.lastReadingDao = new BinaryFileReadingDao(this); } ReadingDto lastReadingDto; if (dto.LastReading != null) { lastReadingDto = dto.LastReading; } else { lastReadingDto = new ReadingDto(); lastReadingDto.Empty = true; } this.lastReadingDao.Create(lastReadingDto); if (this.rangeDao == null) { this.rangeDao = new BinaryFileRangeDao(this); } this.rangeDao.Create(dto.Range); }
public void SetupFileNameTest_ValidCases_Barcode(string fileName, DataSourceEnum type, string errorMsg) { var sourceDto = new DataSourceDto(); var exception = Record.Exception(() => { sourceDto.SetupFileName(fileName, type); }); Assert.Null(exception); Assert.True(!string.IsNullOrWhiteSpace(sourceDto.BarcodeFilename), errorMsg); }
public void SetupFileNameTest_InvalidCases(string fileName, DataSourceEnum type) { // Should throw exception due to data source type invalid. var sourceDto = new DataSourceDto(); var exception = Record.Exception(() => { sourceDto.SetupFileName(fileName, type); }); Assert.NotNull(exception); Assert.Null(sourceDto.BarcodeFilename); Assert.Null(sourceDto.CatalogFilename); Assert.Null(sourceDto.SupplierFileName); }
private void ReadDataSources() { foreach (BinaryFileFixup fixup in this.dataSourceFixupTable) { if (fixup.Position != BinaryFileDao.UnknownOffset) { BinaryFileDataSourceDao dataSourceDao = new BinaryFileDataSourceDao(this); dataSourceDao.Fixup = fixup; DataSourceDto dataSourceDto = dataSourceDao.Read(); this.DataSources.Add(dataSourceDao); this.dto.AddDataSource(dataSourceDto); } } }
private DataSource ToEntity(DataSourceDto dto) { if (dto == null) { return(null); } return(new DataSource( dto.Id, dto.Name, dto.Created, dto.UserId, dto.Schema, dto.Value)); }
public IHttpActionResult CreateDataSource(DataSourceDto dataSourceDto) { if (!ModelState.IsValid) { return(BadRequest()); } var dataSource = Mapper.Map <DataSourceDto, DataSource>(dataSourceDto); _context.DataSources.Add(dataSource); _context.SaveChanges(); dataSourceDto.Id = dataSource.Id; return(Created(new Uri(Request.RequestUri + "/" + dataSource.Id), dataSourceDto)); }
public DataSourceDto Read() { DataSourceDto dto = this.dto = new DataSourceDto(); this.dto.Dao = this; SeekPosition(); ReadAttributes(); if (this.statsDao == null) { this.statsDao = new BinaryFileDataSourceStatsDao(this); } this.dto.Stats = this.statsDao.Read(); this.dto.Archives = this.archives.Read(); this.dto = null; return(dto); }
public void SetupDataSourceDto_by_constructor() { var companyName = "Compnay A"; var companyId = 1; var targetType = DataSourceEnum.Catalog; var fileName = "catalogA.csv"; var testObj = new DataSourceDto(companyId, companyName, fileName, targetType); Assert.NotNull(testObj); Assert.Equal(companyId, testObj.SourceId); Assert.Equal(companyName, testObj.SourceName); Assert.Equal(fileName, testObj.CatalogFilename); Assert.True(string.IsNullOrWhiteSpace(testObj.SupplierFileName)); Assert.True(string.IsNullOrWhiteSpace(testObj.BarcodeFilename)); }
public IList <DataSourceDto> GetSeniorityLevelsDataSource() { IList <DataSourceDto> dataSource = new List <DataSourceDto>(); foreach (SeniorityLevel result in Enum.GetValues(typeof(SeniorityLevel))) { var newDataItem = new DataSourceDto() { ID = (int)result, Name = result.ToString() }; dataSource.Add(newDataItem); } return(dataSource); }
public IHttpActionResult UpdateDataSource(int id, DataSourceDto dataSourceDto) { if (!ModelState.IsValid) { return(BadRequest()); } var dataSourceInDb = _context.DataSources.SingleOrDefault(c => c.Id == id); if (dataSourceInDb == null) { return(NotFound()); } Mapper.Map(dataSourceDto, dataSourceInDb); _context.SaveChanges(); return(Ok()); }
public IList <DataSourceDto> GetResultsDataSource() { IList <DataSourceDto> dataSource = new List <DataSourceDto>(); foreach (GameResult result in Enum.GetValues(typeof(GameResult))) { var newDataItem = new DataSourceDto() { ID = (int)result, Name = result.ToString() }; if (result == GameResult.Draw) { newDataItem.Name = DRAW_RESULT_TEXT; } dataSource.Add(newDataItem); } return(dataSource); }
public void Create(DataSourceDto dto) { this.fixup = this.databaseDao.FindDataSourceFixupByName(dto.Name); CreateAttributes(dto); this.fixup.Write(); }