public ActionResult DeleteConfirmed(int id)
        {
            RoomBookingService roomBookingService = db.RoomBookingServices.Find(id);

            db.RoomBookingServices.Remove(roomBookingService);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "RoomBookingID,ServiceID,OderDate")] RoomBookingService roomBookingService)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roomBookingService).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoomBookingID = new SelectList(db.RoomBookings, "RoomBookingID", "RoomID", roomBookingService.RoomBookingID);
     ViewBag.ServiceID     = new SelectList(db.RoomServices, "ServiceID", "Name", roomBookingService.ServiceID);
     return(View(roomBookingService));
 }
        // GET: RoomBookingServices/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomBookingService roomBookingService = db.RoomBookingServices.Find(id);

            if (roomBookingService == null)
            {
                return(HttpNotFound());
            }
            return(View(roomBookingService));
        }
        // GET: RoomBookingServices/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomBookingService roomBookingService = db.RoomBookingServices.Find(id);

            if (roomBookingService == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RoomBookingID = new SelectList(db.RoomBookings, "RoomBookingID", "RoomID", roomBookingService.RoomBookingID);
            ViewBag.ServiceID     = new SelectList(db.RoomServices, "ServiceID", "Name", roomBookingService.ServiceID);
            return(View(roomBookingService));
        }
        public void Test_RoomBookingsForAccount()
        {
            // -- Arrange --
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            // We are using  TestDataContext to prevent database seeding
            var options = new DbContextOptionsBuilder <DataContext>().UseSqlite(connection).Options;

            var context = new TestDataContext(options);

            context.Database.EnsureCreated();

            // Add some test accounts
            context.Accounts.AddRange(_testAccounts);
            context.SaveChanges();

            // Add some test rooms
            context.Rooms.AddRange(_testRooms);
            context.SaveChanges();

            // Add some test bookings
            List <RoomBooking> testRoomBookings = new List <RoomBooking>
            {
                new RoomBooking {
                    RoomBookingId = 1, AccountId = 1, RoomId = 2, StartDate = DateTime.MinValue, EndDate = DateTime.MinValue, PersonCount = 2, CalculatedPrice = 0
                },
                new RoomBooking {
                    RoomBookingId = 2, AccountId = 1, RoomId = 3, StartDate = DateTime.MinValue, EndDate = DateTime.MinValue, PersonCount = 2, CalculatedPrice = 0
                },
                new RoomBooking {
                    RoomBookingId = 3, AccountId = 1, RoomId = 4, StartDate = DateTime.MinValue, EndDate = DateTime.MinValue, PersonCount = 2, CalculatedPrice = 0
                },
                new RoomBooking {
                    RoomBookingId = 4, AccountId = 2, RoomId = 1, StartDate = DateTime.MinValue, EndDate = DateTime.MinValue, PersonCount = 2, CalculatedPrice = 0
                },
                new RoomBooking {
                    RoomBookingId = 5, AccountId = 2, RoomId = 4, StartDate = DateTime.MinValue, EndDate = DateTime.MinValue, PersonCount = 2, CalculatedPrice = 0
                },
                new RoomBooking {
                    RoomBookingId = 6, AccountId = 3, RoomId = 1, StartDate = DateTime.MinValue, EndDate = DateTime.MinValue, PersonCount = 2, CalculatedPrice = 0
                },
            };

            context.RoomBookings.AddRange(testRoomBookings);
            context.SaveChanges();

            // Set up mocks ready to create the RoomBookingService
            var mockLogger = new Mock <ILogger <RoomBookingService> >();

            // If we need to mock any ILogger properties then do that here...

            // Create the RoomBookingService object for testing
            var roomBookingService = new RoomBookingService(mockLogger.Object, context);

            // -- Act --
            var result = roomBookingService.RoomBookingsForAccount(2).ToList();

            // -- Assert --
            Assert.IsTrue(result.Count() == 2, "Unexpected number of bookings returned!");
            CollectionAssert.AreEquivalent(new long[] { 4, 5 }, result.Select(b => b.RoomBookingId).OrderBy(b => b), "Unexpected booking details returned!");

            connection.Close();
        }