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!"); }
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); }
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!")); }
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)); }