예제 #1
0
        public IActionResult Update([FromBody] RoomViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is not valid"));
            }

            try
            {
                this.updateRoomCommand.RoomModel = RoomBuilder.BuildFromInfo(viewModel);
                this.updateRoomCommand.Execute();
                return(this.Ok());
            }
            catch (DoorsAreNotInWallsException)
            {
                return(BadRequest("Doors coordinates are invalid"));
            }
            catch (DuplicatedKeyException)
            {
                return(BadRequest("Room with this number already exists"));
            }
            catch (RoomIsIntersectedWithExisting)
            {
                return(BadRequest("Room is interssected with other room on this floor"));
            }
        }
예제 #2
0
 public virtual IEnumerable <Room> GetAll()
 {
     try
     {
         var queryResult = this.rooms.Find(u => true).ToList();
         return(queryResult.Select(mongoModel => RoomBuilder.BuildFromInfo(mongoModel)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }