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; })); }
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); }
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() + ");\"> </li>"); sb.Append("<li onmouseover=\"amaf_hoverRate(this,2);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(2," + TopicId.ToString() + ");\"> </li>"); sb.Append("<li onmouseover=\"amaf_hoverRate(this,3);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(3," + TopicId.ToString() + ");\"> </li>"); sb.Append("<li onmouseover=\"amaf_hoverRate(this,4);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(4," + TopicId.ToString() + ");\"> </li>"); sb.Append("<li onmouseover=\"amaf_hoverRate(this,5);\" onmouseout=\"amaf_hoverRate(this);\" onclick=\"amaf_changeRate(5," + TopicId.ToString() + ");\"> </li>"); } else { sb.Append("<li> </li>"); sb.Append("<li> </li>"); sb.Append("<li> </li>"); sb.Append("<li> </li>"); sb.Append("<li> </li>"); } sb.Append("</ul>"); if (Enabled) { sb.Append("<input type=\"hidden\" value=\"" + Rating.ToString() + "\" id=\"af-rate-value\" />"); } return(sb.ToString()); }