public async Task <ActionResult <Ad> > GetAd(string id) { var ad = await adService.GetAd(id); if (ad == null) { return(NotFound()); } return(ad); }
public IActionResult Post(int id) { var dto = ass.GetAd(id); if (dto == null) { return(NotFound("post not found")); } else { return(View("Post", dto)); } }
public void GetAd() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Get_Ad") .Options; var ad = new Ad { Id = 1 }; Ad expectedAd; using (var db = new ApplicationDbContext(options)) { db.Ads.Add(ad); db.SaveChanges(); AdService service = new AdService(db); expectedAd = service.GetAd(ad.Id); } Assert.Equal(ad.Id, expectedAd.Id); }
public AdDto Get(int id) { return(service.GetAd(id)); }