Beispiel #1
0
 public RoomType MapUpdateRoomTypeViewModelToModel(UpdateRoomTypeViewModel updateRoomTypeViewModel, RoomType roomType)
 {
     roomType.ID    = updateRoomTypeViewModel.ID;
     roomType.Name  = updateRoomTypeViewModel.Name;
     roomType.Rooms = updateRoomTypeViewModel.Rooms;
     return(roomType);
 }
Beispiel #2
0
 public IActionResult Put(int id, [FromBody] UpdateRoomTypeViewModel updateRoomTypeViewModel)
 {
     if (updateRoomTypeViewModel != null)
     {
         updateRoomTypeViewModel.ID = id;
         RoomType roomType = new RoomType();
         roomType = iUpdateRoomTypeMapper.MapUpdateRoomTypeViewModelToModel(updateRoomTypeViewModel, roomType);
         if (string.IsNullOrEmpty(roomType.Name))
         {
             roomType.Name = iRoomTypeRepository.GetRoomTypeByID(roomType.ID).Name;
         }
         iRoomTypeRepository.UpdateRoomType(roomType);
         iUnitOfWork.Save();
         return(Ok(roomType));
     }
     else
     {
         return(NotFound("Room Type with ID " + id.ToString() + " was not found."));
     }
 }