Exemplo n.º 1
0
        public SearchSensorByRoomCommandResult Handle(SearchSensorByRoomCommand command)
        {
            SearchSensorByRoomCommandResult result = new SearchSensorByRoomCommandResult();

            ObjectId roomId;

            if (!ObjectId.TryParse(command.RoomId, out roomId))
            {
                AddNotification(nameof(command.RoomId), ENotifications.InvalidFormat);
            }

            if (Valid)
            {
                List <ObjectId> sensors = _sensorRepository.SearchByRoom(roomId).ToList();

                if (sensors.Count > 0)
                {
                    result = new SearchSensorByRoomCommandResult(HttpStatusCode.OK, sensors);
                }

                else if (_sensorRepository.Valid)
                {
                    result = new SearchSensorByRoomCommandResult(HttpStatusCode.NoContent);
                }
            }

            else
            {
                result = new SearchSensorByRoomCommandResult(HttpStatusCode.BadRequest, Notifications);
            }

            return(result);
        }
Exemplo n.º 2
0
        public SearchSensorByRoomCommandResult SearchByRoom(string room)
        {
            SearchSensorByRoomCommand command = new SearchSensorByRoomCommand();

            command.SetRoomId(room);

            return(Execute <SearchSensorByRoomCommand, SearchSensorByRoomCommandResult>(command));
        }