public void RatePage(RatingDto ratingData) { ContentReference reviewPageReference; if (ContentReference.TryParse(ratingData.ContentId, out reviewPageReference)) { var review = new ReviewModel() { Rating = ratingData.Rating ? 1 : -1, ReviewText = ratingData.Comment, ReviewOwnerContentLink = reviewPageReference }; _reviewService.Create(review); AddCookie(ratingData.ContentId); SendNotificationEmail(); } else { _logger.Log(Level.Error, $"Error parsing content reference {ratingData.ContentId}"); } }
public ResponseDto PageIsPublished(RatingDto actionInfo) { ContentReference reviewPageReference; var response = new ResponseDto(); if (ContentReference.TryParse(actionInfo.ContentId, out reviewPageReference)) { var page = _loader.Get<PageData>(reviewPageReference); response.PageIsPublished = page.Status == VersionStatus.Published; } return response; }
public void EnableRating(RatingDto actionInfo) { ContentReference reviewPageReference; if (ContentReference.TryParse(actionInfo.ContentId, out reviewPageReference)) { var page = _loader.Get<PageData>(reviewPageReference); var writablePage = page.CreateWritableClone(); var ratingPage = writablePage as IRatingPage; if (ratingPage != null) { ratingPage.RatingEnabled = actionInfo.RatingEnabled; } _repository.Save(writablePage, EPiServer.DataAccess.SaveAction.Publish); } }