Exemple #1
0
 private void HidePinCode(ExternalReviewLink externalReviewLink)
 {
     if (!string.IsNullOrWhiteSpace(externalReviewLink.PinCode))
     {
         externalReviewLink.PinCode = "****";
     }
 }
        public ExternalReviewLink AddLink(ContentReference contentLink, bool isEditable, TimeSpan validTo)
        {
            var externalReviewLink = new ExternalReviewLinkDds
            {
                ContentLink = contentLink,
                IsEditable  = isEditable,
                Token       = Guid.NewGuid().ToString(),
                ValidTo     = DateTime.Now.Add(validTo)
            };

            GetStore().Save(externalReviewLink);
            return(ExternalReviewLink.FromExternalReview(externalReviewLink, _externalReviewOptions.ReviewsUrl, _externalReviewOptions.ContentPreviewUrl));
        }
        public ExternalReviewLink GetContentByToken(string token)
        {
            if (string.IsNullOrWhiteSpace(token))
            {
                return(null);
            }

            token = token.ToLower();
            var externalReviewLinkDds = GetStore().Items <ExternalReviewLinkDds>()
                                        .FirstOrDefault(x => x.Token == token);

            if (externalReviewLinkDds == null)
            {
                return(null);
            }
            return(ExternalReviewLink.FromExternalReview(externalReviewLinkDds, _externalReviewOptions.ReviewsUrl, _externalReviewOptions.ContentPreviewUrl));
        }
Exemple #4
0
        private async Task <bool> SendMail(ExternalReviewLink externalReviewLink, string email, string subject,
                                           string message)
        {
            var linkUrl = new Uri(SiteDefinition.Current.SiteUrl, externalReviewLink.LinkUrl);

            message = message.Replace("[#link#]", linkUrl.ToString());

            var providerNotificationMessages = new List <ProviderNotificationMessage>
            {
                new ProviderNotificationMessage
                {
                    Content            = message,
                    RecipientAddresses = new[] { email },
                    SenderAddress      = _notificationOptions.NotificationEmailAddress,
                    Subject            = subject,
                    SenderDisplayName  = _notificationOptions.NotificationEmailDisplayName
                }
            };
            var result = true;
            await _emailNotificationProvider.SendAsync(providerNotificationMessages, msg => { result = true; },
                                                       (msg, exception) => { result = false; }).ConfigureAwait(true);

            return(result);
        }
 public IEnumerable <ExternalReviewLink> GetLinksForContent(ContentReference contentLink)
 {
     return(GetStore().Items <ExternalReviewLinkDds>().Where(x => x.ContentLink == contentLink).ToList().Select(x =>
                                                                                                                ExternalReviewLink.FromExternalReview(x, _externalReviewOptions.ReviewsUrl, _externalReviewOptions.ContentPreviewUrl)));
 }
Exemple #6
0
 public static bool IsExpired(this ExternalReviewLink externalReviewLink)
 {
     return(externalReviewLink.ValidTo < DateTime.Now);
 }
Exemple #7
0
 public static bool IsPreviewableLink(this ExternalReviewLink externalReviewLink)
 {
     return(externalReviewLink != null &&
            !externalReviewLink.IsExpired() &&
            !externalReviewLink.IsEditable);
 }