public async Task ShoutReturnAll() { var assetsFromRepo = await repo.GetAll(); assetsFromRepo.Should().HaveCount(2); var expectedCollection = new List <Asset>() { new Asset() { Id = 1, Type = "MotorVehicle", BasePrice = 66, Identification = "VH1233" }, new Asset() { Id = 2, Type = "MotorVehicle", BasePrice = 99, Identification = "MTZ-2231", } }; assetsFromRepo.Should().BeEquivalentTo(expectedCollection); }
public List <Asset> GetAllAssets() { var assets = AssetRepository.GetAll(); if (MBFileService == null) { return(assets); } foreach (Asset asset in assets) { asset.MBFile = (IMBFile)MBFileService.GetByRelativePath(asset.RelativePath); } return(assets); }
static async Task TestSomeCalls() { Console.WriteLine(@"Enter Servername to test(i.e. mydbserver\sqlexpress):"); string readServerName = Console.ReadLine(); Console.WriteLine("Enter Username:"******"Enter Password:"******"localhost\sqlexpress" : readServerName; string login = String.IsNullOrWhiteSpace(readServerName) ? "sa" : readUsername; string password = String.IsNullOrWhiteSpace(readPassword) ? "my_sa_passworx" : readPassword; DbOptions dbOption = new DbOptions() { DbHostname = server, DbName = "AssetWorx", DbUsername = login, DbPassword = password, DbType = "Sql Server" }; SqlServerFormatter sqlServerFormatter = new SqlServerFormatter(dbOption); LocationRepository locationRepo = new LocationRepository(dbOption, sqlServerFormatter); ApplicationSettingRepository appSettingsRepo = new ApplicationSettingRepository(dbOption, sqlServerFormatter); LocationHistoryRepository locationHistoryRepo = new LocationHistoryRepository(dbOption, sqlServerFormatter); EventRepository eventRepo = new EventRepository(dbOption, appSettingsRepo, sqlServerFormatter); MapAreaRepository mapAreaRepo = new MapAreaRepository(dbOption, sqlServerFormatter); AssetRepository assetRepo = new AssetRepository(dbOption, locationRepo, locationHistoryRepo, eventRepo, appSettingsRepo, mapAreaRepo, sqlServerFormatter); List <Asset> assets = await assetRepo.GetAll(null, null, null); Console.WriteLine("***************ALL ASSETS**************"); foreach (Asset asset in assets) { Console.WriteLine(string.Format("Got asset {0}", asset.Name)); } assets = await assetRepo.GetChangedAssets(DateTimeOffset.Now.AddDays(-10)); Console.WriteLine("***************CHANGED ASSETS**************"); foreach (Asset asset in assets) { Console.WriteLine(string.Format("Got changed asset {0}", asset.Name)); } Console.ReadLine(); }
public static IPagedResponse <IAsset> GetAssets(int pageNumber, int pageSize) { if (pageNumber <= 0) { throw new ArgumentException("Page number must exceed 0."); } if (pageSize <= 0) { throw new ArgumentException("Page size must exceed 0."); } using (AssetRepository repo = new AssetRepository()) { return(repo.GetAll(pageNumber, pageSize)); } }
public HttpResponseMessage AddSubAsset(string blobName, string version, string subAssetUrl) { var asset = assetRep.GetAll().Where(d => d.CustomName == blobName).FirstOrDefault(); if (asset != null) { if (asset.Type == "image") { SubAsset subasset = new SubAsset(); subasset.AssetId = asset.AssetId; subasset.asset = asset; subasset.Version = version; subasset.SubAssetUrl = subAssetUrl; subAssetRep.Create(subasset); return(new HttpResponseMessage(HttpStatusCode.Accepted)); } } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public IList <Asset> GetAllAssets() { return(_assetRepository.GetAll()); }
public async Task <IEnumerable <AssetDTO> > ListAssets() { var assets = await _repo.GetAll(); return(assets.Select(x => _mapper.Map <AssetDTO>(x))); }