public async Task <IActionResult> ImportData(string url, string importSource) { IParsingClient _parsingClient = null; if (!_linkValidator.ValidateProfileLink(url, importSource)) { return(BadRequest()); } switch (importSource) { case "etsy": _parsingClient = new EtsyParsingClient(_watermarkService); break; case "pakamera": _parsingClient = new PakameraParsingClient(_watermarkService); break; } if (_parsingClient != null) { var artList = await _parsingClient.GetArtsFromUser(url); foreach (var art in artList) { await _context.AddAsync(art); } var success = await _context.SaveChangesAsync() > 0; } return(RedirectToAction("Index")); }
public async Task Results_Results_WhenSearchIsTitle() { using (var db = new ArtDbContext(TestingDbContextOptions.TestDbContextOptions())) { var controller = new SearchController(db); var picture = new Picture { Id = 1, IsImage = true, Likes = 10, Title = "Test", UploadDate = DateTime.Now, Url = "//Test", UserId = "test", UserName = "******" }; await db.Pictures.AddAsync(picture); await db.SaveChangesAsync(); string searchTerm = "Test"; controller.Results(searchTerm); Assert.AreEqual(1, controller.PictureResults.Count); } }