Beispiel #1
0
        public async Task <ActionResult <Ad> > GetAd(string id)
        {
            var ad = await adService.GetAd(id);

            if (ad == null)
            {
                return(NotFound());
            }

            return(ad);
        }
Beispiel #2
0
        public IActionResult Post(int id)
        {
            var dto = ass.GetAd(id);

            if (dto == null)
            {
                return(NotFound("post not found"));
            }
            else
            {
                return(View("Post", dto));
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public AdDto Get(int id)
 {
     return(service.GetAd(id));
 }