示例#1
0
        public async Task <HttpResponseMessage> PostCommentOnEvent(int idEvents, [FromBody]  CommentFromUser body)
        {
            //IStateFactory<@event, EventsCollectionState> _stateFactory = new EventsCollectionFactory(new EventLinkFactory(Request));
            var instance = CommentService.GetInstance();
            var token    = GetToken();

            var res = await instance.PostCommentOnEvent(new CreateComment { eventId = idEvents, message = body.comment, authorId = token });

            if (res.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, res.Result, "application/json"));
            }

            return(Request.CreateResponse(HttpStatusCode.Conflict, new Conflict(Request.RequestUri, res.Message), "application/problem+json"));
        }
示例#2
0
        public async Task <HttpResponseMessage> PostCommentOnCommunity(int idCommunity, [FromBody]  CommentFromUser body)
        {
            var instance = CommentService.GetInstance();
            var token    = GetToken();
            var res      = await instance.PostCommentOnCommunity(new CreateComment { communityId = idCommunity, message = body.comment, authorId = token });

            if (res.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, res.Result, "application/json"));
            }

            return(Request.CreateResponse(HttpStatusCode.Conflict, new Conflict(Request.RequestUri, res.Message), "application/problem+json"));
        }