public Booking Add(Booking newBooking)
 {
     try
     {
         db.Bookings.Add(newBooking);
         db.SaveChanges();
         return newBooking;
     }
     catch
     {
         return null;
     }
 }
        public void PostErrorBooking()
        {
            var testBooking = new Booking() { Id = 8, ClientName = "Benedict Mock", Duration = 30, ExpectedDate = DateTime.Now };
            //Setting up the mock
            var mock = new Mock<IBookingRepository>();
            mock.Setup(b => b.Add(It.IsAny<Booking>())).Returns((Booking)null);
            var repo = mock.Object;

            //Inject the mocked repository into controller
            AdvertisementBookingController controller = new AdvertisementBookingController(repo);
            var response = controller.Post(testBooking);

            // Assert
            Assert.IsNull(response);
        }
 public Booking Post(Booking item)
 {
     var newBooking = this._repo.Add(item);
     return newBooking;
 }