public ActionResult AddRoom(AddRoomViewModel viewModel) { var model = FromAddViewModel(viewModel); repository.AddRoom(model); return(Ok( ToViewModel(model) )); }
public IActionResult Post([FromBody] Room room) { if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } var createdRoom = rooms.AddRoom(room); return(CreatedAtAction(nameof(Get), new { id = createdRoom.Id }, createdRoom)); }
public Room AddRoom(Room room) { try { room.Number = FindMaxId(room.AddedBy) + 1; return(roomsRepository.AddRoom(room)); } catch (MongoWriteConcernException ex) { if (ex.Code == 11000) { throw new DuplicateException("User already exists for username and/or email"); } else { throw ex; } } }
public IHttpActionResult InsertRoom(Room room) { _repository.AddRoom(room); return(Ok()); }
//Add a new room public bool AddRoom(RoomDetailViewModel room) { return(_roomsRepository.AddRoom(_mapper.Map <Room>(room))); }