Example #1
0
        public ActionResult GetComments(int?publicationId, int pageId, bool descending = false, int[] status = null,
                                        int top = 0, int skip = 0)
        {
            UgcService ugc      = new UgcService();
            var        comments = ugc.GetComments(
                publicationId ?? int.Parse(WebRequestContext.Localization.Id),
                pageId, descending, status ?? new int[] {}, top, skip);

            if (comments == null)
            {
                return(ServerError(null));
            }
            return(new ContentResult
            {
                ContentType = "application/json",
                Content =
                    JsonConvert.SerializeObject(comments,
                                                new JsonSerializerSettings {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                }),
                ContentEncoding = Encoding.UTF8
            });
        }
Example #2
0
        protected override ViewModel EnrichModel(ViewModel sourceModel)
        {
            UgcComments model = base.EnrichModel(sourceModel) as UgcComments;

            if (model != null)
            {
                var ugcService = new UgcService();
                var comments   = ugcService.GetComments(model.Target.PublicationId, model.Target.ItemId, false,
                                                        new int[] {}, 0, 0);
                model.Comments = CreateEntities(comments);
                return(model);
            }

            UgcPostCommentForm postForm = base.EnrichModel(sourceModel) as UgcPostCommentForm;

            if (postForm != null && MapRequestFormData(postForm) && ModelState.IsValid)
            {
                var ugcService = new UgcService();
                ugcService.PostComment(postForm.Target.PublicationId, postForm.Target.ItemId, postForm.UserName, postForm.EmailAddress, postForm.Content, postForm.ParentId, postForm.Metadata);
                return(new RedirectModel(WebRequestContext.RequestUrl));
            }

            return(sourceModel);
        }