Esempio n. 1
0
        public SearchLightByRoomCommandResult Handle(SearchLightByRoomCommand command)
        {
            SearchLightByRoomCommandResult result = new SearchLightByRoomCommandResult();

            ObjectId roomId;

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

            if (Valid)
            {
                List <ObjectId> lights = _lightRepository.SearchByRoom(roomId).ToList();

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

                else if (_lightRepository.Valid)
                {
                    result = new SearchLightByRoomCommandResult(HttpStatusCode.NoContent);
                }
            }

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

            return(result);
        }
Esempio n. 2
0
        public SearchLightByRoomCommandResult SearchByRoom(string room)
        {
            SearchLightByRoomCommand command = new SearchLightByRoomCommand();

            command.SetRoomId(room);

            return(Execute <SearchLightByRoomCommand, SearchLightByRoomCommandResult>(command));
        }