Пример #1
0
        public async Task <ActionResult <Ad> > GetAd(string id)
        {
            var ad = await adService.GetAd(id);

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

            return(ad);
        }
Пример #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));
            }
        }
Пример #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);
        }
Пример #4
0
 public AdDto Get(int id)
 {
     return(service.GetAd(id));
 }