public RoomType MapCreateRoomTypeViewModelToModel(CreateRoomTypeViewModel createRoomTypeViewModel, RoomType roomType)
 {
     roomType.ID    = createRoomTypeViewModel.ID;
     roomType.Name  = createRoomTypeViewModel.Name;
     roomType.Rooms = createRoomTypeViewModel.Rooms;
     return(roomType);
 }
示例#2
0
 public IActionResult Post([FromBody] CreateRoomTypeViewModel createRoomTypeViewModel)
 {
     try
     {
         RoomType roomType = new RoomType();
         if (!string.IsNullOrEmpty(createRoomTypeViewModel.Name))
         {
             roomType = iCreateRoomTypeMapper.MapCreateRoomTypeViewModelToModel(createRoomTypeViewModel, roomType);
             iRoomTypeRepository.CreateRoomType(roomType);
         }
         Uri uri = new Uri(Url.Link("GetRoomTypeByID", new { Id = roomType.ID }));
         iUnitOfWork.Save();
         return(Created(uri, roomType.ID.ToString()));
     }
     catch (Exception ex)
     {
         return(Content(ex.ToString(), BadRequest().ToString()));
     }
 }