Beispiel #1
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()));
     }
 }