示例#1
0
        public Task <Subscription> UpsertAsync(string appId, string userId, TopicId prefix, ICommand <Subscription> command, CancellationToken ct)
        {
            Guard.NotNull(command, nameof(command));

            return(Updater.UpdateRetriedAsync(5, async() =>
            {
                var(subscription, etag) = await repository.GetAsync(appId, userId, prefix, ct);

                if (subscription == null)
                {
                    if (!command.CanCreate)
                    {
                        throw new DomainObjectNotFoundException(prefix.ToString());
                    }

                    subscription = Subscription.Create(appId, userId, prefix);
                }

                await command.ExecuteAsync(subscription, serviceProvider, ct);

                await repository.UpsertAsync(subscription, etag, ct);

                return subscription;
            }));
        }
示例#2
0
        public XmlNode ToXml(XmlDocument d)
        {
            XmlNode tx = d.CreateElement("comment");

            tx.AppendChild(umbraco.xmlHelper.addCDataNode(d, "body", Body));

            tx.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "id", Id.ToString()));
            tx.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "topicId", TopicId.ToString()));
            tx.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "memberId", MemberId.ToString()));

            tx.Attributes.Append(umbraco.xmlHelper.addAttribute(d, "created", Created.ToString()));

            return(tx);
        }
示例#3
0
        public string Render()
        {
            StringBuilder sb = new StringBuilder();

            if (Rating == -1)
            {
                Rating = DataProvider.Instance().Topics_GetRating(TopicId);
            }
            if (Enabled)
            {
                sb.Append("<ul id=\"af-rater\" class=\"af-rater ");
            }
            else
            {
                sb.Append("<ul class=\"af-rater ");
            }

            if (Rating > 0)
            {
                sb.Append(" rate" + Rating.ToString());
            }
            sb.Append("\">");
            if (Enabled)
            {
                sb.Append("<li onmouseover=\"amaf_hoverRate(this,1);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(1," + TopicId.ToString() + ");\">&nbsp;</li>");
                sb.Append("<li onmouseover=\"amaf_hoverRate(this,2);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(2," + TopicId.ToString() + ");\">&nbsp;</li>");
                sb.Append("<li onmouseover=\"amaf_hoverRate(this,3);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(3," + TopicId.ToString() + ");\">&nbsp;</li>");
                sb.Append("<li onmouseover=\"amaf_hoverRate(this,4);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(4," + TopicId.ToString() + ");\">&nbsp;</li>");
                sb.Append("<li onmouseover=\"amaf_hoverRate(this,5);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(5," + TopicId.ToString() + ");\">&nbsp;</li>");
            }
            else
            {
                sb.Append("<li>&nbsp;</li>");
                sb.Append("<li>&nbsp;</li>");
                sb.Append("<li>&nbsp;</li>");
                sb.Append("<li>&nbsp;</li>");
                sb.Append("<li>&nbsp;</li>");
            }

            sb.Append("</ul>");
            if (Enabled)
            {
                sb.Append("<input type=\"hidden\" value=\"" + Rating.ToString() + "\" id=\"af-rate-value\" />");
            }

            return(sb.ToString());
        }