Ajax N2 CMS分级用户控制
我目前正在N2 CMS框架中建立一个站点。我想做的一件事是让用户使用一个相当标准的星级风格的用户控件或类似的东西对网站的各种元素进行评级 是否有人在N2中实现了类似的功能?只是想寻找一些在N2中实现这一点的最佳方法 另外,我不认为这会有什么不同,但我目前正在N2中使用ASP MVC实现所有这些 提前谢谢 Paul检查BlogSvc(即将被称为AtomServer)的功能 Source/WebCore/Plugins/Rater/RaterService.cs 以下是一个片段:Ajax N2 CMS分级用户控制,ajax,rating,n2,Ajax,Rating,N2,我目前正在N2 CMS框架中建立一个站点。我想做的一件事是让用户使用一个相当标准的星级风格的用户控件或类似的东西对网站的各种元素进行评级 是否有人在N2中实现了类似的功能?只是想寻找一些在N2中实现这一点的最佳方法 另外,我不认为这会有什么不同,但我目前正在N2中使用ASP MVC实现所有这些 提前谢谢 Paul检查BlogSvc(即将被称为AtomServer)的功能 Source/WebCore/Plugins/Rater/RaterService.cs 以下是一个片段: public Ra
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
};
}
public RaterModel Rate(Id entryId、float rating、User User、string ip)
{
LogService.Info(“RateEntry:{0}、{1}、{2}”、entryId、rating、ip);
如果(!AuthorizeService.IsAuthorized(用户、entryId、AuthAction.RateEntryOrMedia))
抛出新的UserNotAuthorizedException(user.Name、AuthAction.RateEntryOrMedia.ToString());
如果(评级<1 | |评级>5)抛出新ArgumentOutOfRangeException(“评级值必须为1到5”);
AtomEntry entry=AtomEntryRepository.GetEntry(entryId);
if(entry.Raters.Contains(ip))抛出新的UseralReadyRateEntryException(ip,entry.Id.ToString());
entry.RatingCount++;
entry.RatingSum+=(int)Math.Round(rating);//临时强制int评级
entry.Edited=DateTimeOffset.UtcNow;
List raters=entry.raters.ToList();
增加(ip);
条目。评分员=评分员;
entry=AtomEntryRepository.UpdateEntry(条目);
返回新的RaterModel()
{
PostHref=RouteService.RouteUrl(“RaterRateEntry”,entryId),
评级=输入。评级,
CanRate=false,
RatingCount=entry.RatingCount
};
}
这是我在网站上对内容进行评级的方法-1到5颗星
N2CMS-EditableEnum非常适合此工作
[EditableEnum("RatingValue", 2, typeof(Rating))]
public virtual string RatingValue
{
get { return (string)(GetDetail("RatingValue")); }
set { SetDetail("RatingValue", value); }
}
/// <summary>
/// Enum for the Vehicle Review Ratings
/// </summary>
public enum Rating
{
one = 1,
two = 2,
three = 3,
four = 4,
five = 5
}
[EditableEnum(“评级值”,2,类型(评级))]
公共虚拟字符串比率值
{
获取{return(string)(GetDetail(“RatingValue”);}
set{SetDetail(“RatingValue”,value);}
}
///
///车辆审查评级的枚举
///
公共枚举评级
{
1=1,
二等于二,
三等于三,
四等于四,
五等于五
}
有用的链接,但不是我想要的,理想情况下需要与N2更好的集成。谢谢。你写C#感到舒服吗?如果是这样的话,用一个用户控件和一个额外的页面项就可以很容易地做到这一点。是的,我实际上在最后做了一些非常类似的事情。我只是懒洋洋的,希望能有一些好东西,开箱即用,我可以重复使用。谢谢你的建议。