예제 #1
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);
            }
        }
예제 #2
0
        public object Delete(DeleteTopic request)
        {
            IDbTransaction transaction = Db.OpenTransaction();

            try
            {
                DeletingTopic.Delete(request);
            }
            catch (TopicNotExistsException)
            {
                return(new HttpError(HttpStatusCode.NotFound, $"Topic {request.TopicName} not exists"));
            }
            catch (BadRequestException)
            {
                return(new HttpError(HttpStatusCode.BadRequest, "BadRequest"));
            }
            finally
            {
                transaction.Commit();
            }

            return(new HttpResult(new DeleteTopicResponse(), HttpStatusCode.NoContent));
        }