public object Post(CreateTopic request)
        {
            IDbTransaction transaction = Db.OpenTransaction();

            try
            {
                CreatingTopic.Create(request);
            }
            catch (TopicAlreadyExistsException)
            {
                return(new HttpError(HttpStatusCode.Conflict, $"Topic {request.Name} already exists"));
            }
            catch (BadRequestException)
            {
                return(new HttpError(HttpStatusCode.BadRequest, "BadRequest"));
            }
            finally
            {
                transaction.Commit();
            }

            return(new HttpResult(new CreateQueueResponse())
            {
                StatusCode = HttpStatusCode.Created,
                Headers =
                {
                    { HttpHeaders.Location, base.Request.AbsoluteUri.CombineWith(request.Name) }
                }
            });
        }
Beispiel #2
0
        public object Delete(DeleteMessage request)
        {
            IDbTransaction transaction = Db.OpenTransaction();

            try
            {
                DeletingMessage.Delete(request);
            }
            catch (QueueNotExistsException)
            {
                return(new HttpError(HttpStatusCode.NotFound, $"Queue {request.QueueName} not exists"));
            }
            catch (BadRequestException)
            {
                return(new HttpError(HttpStatusCode.BadRequest, "BadRequest"));
            }
            finally
            {
                transaction.Commit();
            }

            return(new HttpResult(new DeleteMessageResponse(), HttpStatusCode.NoContent));
        }
        public object Delete(DeleteAnnouncement request)
        {
            IDbTransaction transaction = Db.OpenTransaction();

            try
            {
                var subscriberId = this.GetSession().UserAuthId.ToInt();
                DeletingAnnouncement.Delete(request, subscriberId);
            }
            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 DeleteAnnouncementResponse(), HttpStatusCode.NoContent));
        }