Пример #1
0
        public IActionResult GetRoomTypeByID(int id)
        {
            RoomType roomType = iRoomTypeRepository.GetRoomTypeByID(id);

            if (roomType != null)
            {
                return(Ok(roomType));
            }
            else
            {
                return(NotFound("Room Type with ID " + id.ToString() + " was not found."));
            }
        }
Пример #2
0
 public IActionResult Post([FromBody] CreateRoomViewModel createRoomViewModel)
 {
     try
     {
         Room room = new Room()
         {
             ID               = createRoomViewModel.ID,
             Number           = createRoomViewModel.Number,
             RoomType         = createRoomViewModel.RoomType,
             RoomReservations = createRoomViewModel.RoomReservations
         };
         if (room.RoomType != null && room.RoomType.ID != 0)
         {
             RoomType roomTypeFromDropDownList = iRoomTypeRepository.GetRoomTypeByID(room.RoomType.ID);
             room.RoomType = roomTypeFromDropDownList;
         }
         iRoomRepository.CreateRoom(room);
         Uri uri = new Uri(Url.Link("GetRoomByID", new { Id = room.ID }));
         iUnitOfWork.Save();
         return(Created(uri, room.ID.ToString()));
     }
     catch (Exception ex)
     {
         return(Content(ex.ToString(), BadRequest().ToString()));
     }
 }
Пример #3
0
 public void UpdateRoomValidation(Room room)
 {
     if (room.RoomType.ID != 0)
     {
         RoomType roomTypeFromDropDownList = iRoomTypeRepository.GetRoomTypeByID(room.RoomType.ID);
         room.RoomType = roomTypeFromDropDownList;
     }
     else
     {
         room.RoomType = iRoomRepository.GetRoomByID(room.ID).RoomType;
     }
     if (room.Number == 0)
     {
         room.Number = iRoomRepository.GetRoomByID(room.ID).Number;
     }
     else
     {
         room.Number = room.Number;
     }
 }