(すぐAtomサーバーと呼ばれるように)BlogSvcのsource codeを確認
ソース/ WebCore /プラグイン/評価者/ RaterService.cs
がAでスニペット:
public RaterModel Rate(Id entryId, float rating, User user, string ip)
{
LogService.Info("RateEntry: {0}, {1}, {2}", entryId, rating, ip);
if (!AuthorizeService.IsAuthorized(user, entryId, AuthAction.RateEntryOrMedia))
throw new UserNotAuthorizedException(user.Name, AuthAction.RateEntryOrMedia.ToString());
if (rating < 1 || rating > 5) throw new ArgumentOutOfRangeException("Rating value must be 1 thru 5.");
AtomEntry entry = AtomEntryRepository.GetEntry(entryId);
if (entry.Raters.Contains(ip)) throw new UserAlreadyRatedEntryException(ip, entry.Id.ToString());
entry.RatingCount++;
entry.RatingSum += (int)Math.Round(rating); //temporarily force int ratings
entry.Edited = DateTimeOffset.UtcNow;
List<string> raters = entry.Raters.ToList();
raters.Add(ip);
entry.Raters = raters;
entry = AtomEntryRepository.UpdateEntry(entry);
return new RaterModel()
{
PostHref = RouteService.RouteUrl("RaterRateEntry", entryId),
Rating = entry.Rating,
CanRate = false,
RatingCount = entry.RatingCount
};
}
に動作しますが、あなたは、快適な書き込みC#のはありますか?もしそうなら、これはユーザーコントロールと余分なページ項目ではかなり簡単です。 –
AbstractItemは –
ええ、私は実際に最後にそれに非常に似た何かをしました。ちょうど怠け者で、箱の外に何か素敵なものがあることを願って再利用することができました。アドバイスをいただきありがとうございます。 – pauldunlop