示例#1
0
        public async void GetAllReview()
        {
            DbContextOptions <LoveThemBackAPIDbContext> options =
                new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("AllReview")
                .Options;


            using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options))
            {
                var Review = new Review();
                Review.PetID      = 1;
                Review.UserID     = 2;
                Review.Impression = "Snooky";

                var Review2 = new Review();
                Review2.PetID      = 2;
                Review2.UserID     = 2;
                Review2.Impression = "Snooky";

                var ServicesCreate = new ReviewsService(context);
                await ServicesCreate.AddReview(Review);

                await ServicesCreate.AddReview(Review2);

                //READ//
                var getReview = ServicesCreate.GetAll();
                Assert.Equal(2, getReview.Value.Count());
            }
        }
示例#2
0
 public ActionResult <IEnumerable <Review> > Get()
 {
     try
     {
         return(Ok(_revserv.GetAll()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     };
 }
示例#3
0
        public async Task <IActionResult> GetAllReviews()
        {
            var reviews = await ReviewsService.GetAll();

            return(Ok(reviews.ToDtos()));
        }