Esempio n. 1
0
        public DtoRooms GetAllRooms()
        {
            DataModels.ConferenceRoomBookingContext context = ConferenceRoomBookingContext;
            var      objRooms = context.Rooms;
            DtoRooms room     = new DtoRooms();

            room.Rooms = objRooms.ToList();
            room.Total = context.Rooms.Count();
            return(room);
        }
Esempio n. 2
0
        public void TestGetBookings110StatusCode204()
        {
            var mockBookingServiceRepository = new Mock <IRoomBookingServiceRepository>();

            DtoRooms objDtoRooms = null;

            mockBookingServiceRepository.Setup(m => m.GetAvialableRoom(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(objDtoRooms);
            RoomsController objBookingController = new RoomsController(mockBookingServiceRepository.Object);

            IActionResult response = objBookingController.GetAvialableRoom("2019-02-08 12:00:00.000", "2019-02-08 12:10:00.000");

            Assert.AreEqual(204, ((Microsoft.AspNetCore.Mvc.StatusCodeResult)response).StatusCode);
        }
Esempio n. 3
0
        public void TestGetBookingsStatusCode204()
        {
            var mockBookingServiceRepository = new Mock <IRoomBookingServiceRepository>();

            DtoRooms objDtoRooms = null;

            mockBookingServiceRepository.Setup(m => m.GetAllRooms()).Returns(objDtoRooms);
            RoomsController objBookingController = new RoomsController(mockBookingServiceRepository.Object);

            IActionResult response = objBookingController.GetBookings();

            Assert.AreEqual(204, ((Microsoft.AspNetCore.Mvc.StatusCodeResult)response).StatusCode);
        }
Esempio n. 4
0
        public void TestGetBookings110StatusCode200()
        {
            var mockBookingServiceRepository = new Mock <IRoomBookingServiceRepository>();

            DtoRooms objDtoRooms = new DtoRooms();

            objDtoRooms.Total = 10;
            objDtoRooms.Rooms = new System.Collections.Generic.List <WebAppServices.DataModels.Rooms>();

            mockBookingServiceRepository.Setup(m => m.GetAvialableRoom(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(objDtoRooms);
            RoomsController objBookingController = new RoomsController(mockBookingServiceRepository.Object);

            IActionResult response = objBookingController.GetAvialableRoom("2019-02-08 12:00:00.000", "2019-02-08 12:10:00.000");

            Assert.AreEqual(200, ((Microsoft.AspNetCore.Mvc.ObjectResult)response).StatusCode);
        }
Esempio n. 5
0
        public void TestGetBookingsStatusCode200()
        {
            var mockBookingServiceRepository = new Mock <IRoomBookingServiceRepository>();

            DtoRooms objDtoRooms = new DtoRooms();

            objDtoRooms.Total = 10;
            objDtoRooms.Rooms = new System.Collections.Generic.List <WebAppServices.DataModels.Rooms>();

            mockBookingServiceRepository.Setup(m => m.GetAllRooms()).Returns(objDtoRooms);
            RoomsController objBookingController = new RoomsController(mockBookingServiceRepository.Object);

            IActionResult response = objBookingController.GetBookings();

            Assert.AreEqual(200, ((Microsoft.AspNetCore.Mvc.ObjectResult)response).StatusCode);
        }
Esempio n. 6
0
 public IActionResult GetBookings()
 {
     try
     {
         DtoRooms returnValue = _repository.GetAllRooms();
         if (returnValue != null && returnValue.Total > 0)
         {
             return(Ok(returnValue));
         }
         return(NoContent());
     }
     catch (Exception exp)
     {
         if (_logger != null)
         {
             _logger.LogCritical(string.Format("Exception for {0}/{1}", "GetBookings", GetInnerErrorMessage(exp)));
         }
         return(BadRequest());
     }
 }
Esempio n. 7
0
 public IActionResult GetAvialableRoom(string bookIn, string bookOut)
 {
     try
     {
         int      currentPage = 0, pageSize = 10;
         DtoRooms returnValue = _repository.GetAvialableRoom(bookIn, bookOut, currentPage, pageSize);
         if (returnValue != null && returnValue.Total > 0)
         {
             return(Ok(returnValue));
         }
         return(NoContent());
     }
     catch (Exception exp)
     {
         if (_logger != null)
         {
             _logger.LogCritical(string.Format("Exception for {0}", "GetBookings With", GetInnerErrorMessage(exp)));
         }
         return(BadRequest());
     }
 }
Esempio n. 8
0
        public DtoRooms GetAvialableRoom(string bookIn, string bookOut, int currentPage, int pageSize)
        {
            DtoRooms room = new DtoRooms();


            List <DataModels.Rooms> objRooms = new List <Rooms>();

            using (var connection = new SqlConnection("Server=.\\SQLEXPRESS;Database=ConferenceRoomBooking;Trusted_Connection=True;"))
            {
                using (var command = new SqlCommand("sp_CheckRoomAvialable", connection)
                {
                    CommandType = CommandType.StoredProcedure
                })
                {
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter("@BookingTimeIn", Convert.ToDateTime(String.Format("{0:MM/dd/yyyy HH:mm:ss}", bookIn.Trim()), CultureInfo.CurrentCulture)));
                    command.Parameters.Add(new SqlParameter("@BookingTimeOut", Convert.ToDateTime(String.Format("{0:MM/dd/yyyy HH:mm:ss}", bookOut.Trim()), CultureInfo.CurrentCulture)));
                    connection.Open();
                    DataTable dt = new DataTable();
                    dt.Load(command.ExecuteReader());

                    objRooms = (from DataRow row in dt.Rows
                                select new Rooms
                    {
                        RoomId = (long)row["RoomId"],
                        RoomName = (string)row["RoomName"],
                        RoomStatus = (long)row["RoomStatus"]
                    }).ToList();

                    room.Total = dt.Rows.Count;
                    room.Rooms = objRooms.ToList();
                    connection.Close();
                }
            }

            return(room);
        }