Пример #1
0
        public void UpdateRoom(int roomId, AddRoomDTO model)
        {
            var room = _mapper.Map <Room>(model);

            room.Id = roomId;
            _hotelAppContext.Rooms.Update(room);
            _hotelAppContext.SaveChanges();
            _logger.LogInformation("Room successfully updated!");
        }
Пример #2
0
        public int CreateRoom(AddRoomDTO model)
        {
            var room = _mapper.Map <Room>(model);

            _hotelAppContext.Rooms.Add(room);
            _hotelAppContext.SaveChanges();
            _logger.LogInformation("Room successfully created!");
            return(room.Id);
        }
Пример #3
0
 public IActionResult UpdateRoom(int roomId, [FromBody] AddRoomDTO model)
 {
     // this method updates a room by providing the rooms id and a model containg all neccessary room parameters
     _roomRepository.UpdateRoom(roomId, model);
     return(Ok("Hotel room successfully updated!"));
 }
Пример #4
0
        public IActionResult AddRoom([FromBody] AddRoomDTO model)
        {   // this method creates a room by providing a string and 3 ints (name, number of beds, price and hotel id)
            var roomId = _roomRepository.CreateRoom(model);

            return(Ok(roomId));
        }