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); } }
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)); }