예제 #1
0
        protected void processRequest(string topicName, RestRequest request)
        {
            if (!TopicsQueries.TopicExists(DBConnection, topicName))
            {
                throw new TopicNotExistsException();
            }
            else
            {
                var topic    = TopicsQueries.getTopicByName(DBConnection, topicName);
                var worker   = WorkerQueries.GetWorkerById(DBConnection, topic.Worker);
                var coworker = WorkerQueries.GetWorkerById(DBConnection, topic.Cooperator);

                PropageteRequestToWorkers(request, topic, worker, coworker);
            }
        }
예제 #2
0
        public void Delete(DeleteTopic request)
        {
            var requestToSend = new RestRequest($"/topics/{request.TopicName}", Method.DELETE);

            if (!TopicsQueries.TopicExists(DBConnection, request.TopicName))
            {
                throw new TopicNotExistsException();
            }
            else
            {
                var topic    = TopicsQueries.getTopicByName(DBConnection, request.TopicName);
                var worker   = WorkerQueries.GetWorkerById(DBConnection, topic.Worker);
                var coworker = WorkerQueries.GetWorkerById(DBConnection, topic.Cooperator);

                TopicsQueries.DeleteTopic(DBConnection, request.TopicName);
                PropageteRequestToWorkers(requestToSend, topic, worker, coworker);
            }
        }
예제 #3
0
        public Announcement Get(GetAnnouncement request, int subscriberId)
        {
            var requestToSend = new RestRequest($"/topics/{request.TopicName}/announcements", Method.GET);

            requestToSend.AddParameter("SubscriberId", subscriberId);

            if (!TopicsQueries.TopicExists(DBConnection, request.TopicName))
            {
                throw new TopicNotExistsException();
            }
            else
            {
                var topic    = TopicsQueries.getTopicByName(DBConnection, request.TopicName);
                var worker   = WorkerQueries.GetWorkerById(DBConnection, topic.Worker);
                var coworker = WorkerQueries.GetWorkerById(DBConnection, topic.Cooperator);

                return(PropageteRequestToWorkers <Announcement>(requestToSend, topic, worker, coworker));
            }
        }
예제 #4
0
        public void Create(CreateTopic request)
        {
            var requestToSend = new RestRequest("topics", Method.POST);

            requestToSend.AddParameter("Name", request.Name);

            if (TopicsQueries.TopicExists(DBConnection, request.Name))
            {
                throw new TopicAlreadyExistsException();
            }
            else
            {
                Worker worker, coworker;
                CalculateTopicWorkers(request.Name, out worker, out coworker);
                var topic = TopicsQueries.CreateTopic(DBConnection, request.Name, worker.Id, coworker.Id);

                PropageteRequestToWorkers(requestToSend, topic, worker, coworker);
            }
        }