コード例 #1
0
        public ActionResult AddRoom(AddRoomViewModel viewModel)
        {
            var model = FromAddViewModel(viewModel);

            repository.AddRoom(model);
            return(Ok(
                       ToViewModel(model)
                       ));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 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;
         }
     }
 }
コード例 #4
0
        public IHttpActionResult InsertRoom(Room room)
        {
            _repository.AddRoom(room);

            return(Ok());
        }
コード例 #5
0
ファイル: RoomService.cs プロジェクト: HasanKumas/Hotel
 //Add a new room
 public bool AddRoom(RoomDetailViewModel room)
 {
     return(_roomsRepository.AddRoom(_mapper.Map <Room>(room)));
 }