2009-03-03 4 views
1

현재 N2 CMS 프레임 워크에 사이트를 구성 중입니다. 내가하고 싶었던 것 중 하나는 사용자가 상당히 표준 별 등급 스타일의 사용자 컨트롤이나 비슷한 것을 사용하여 사이트의 다양한 요소를 평가하도록하는 것이 었습니다.N2 CMS 등급 사용자 정의 컨트롤

누구나 N2 내에서 구현 된 것과 비슷한 것으로 보입니까? 그냥 N2에서 이것을 달성하는 가장 좋은 방법에 대한 몇 가지 포인터를 찾고.

또한 차이가 있다고 생각하지 말고 현재 N2 내에서 ASP MVC를 사용하여이 모든 것을 구현하고 있습니다. 사전에

감사

바울은

+0

당신에게 편안한 쓰기 C#을인가에 대해 완벽하게 작동? 그렇다면 사용자 정의 컨트롤과 추가 페이지 항목을 사용하는 것이 매우 쉽습니다. –

+0

AbstractItem is –

+0

그래, 실제로 실제로는 끝과 비슷한 것을했다. 게으르다가 상자 밖에서 뭔가 재사용 할 수 있기를 바랬습니다. 조언 해주셔서 감사합니다. – pauldunlop

답변

0

소스/WebCore/플러그인/평가 위원/RaterService.cs 여기

가있다 (곧 AtomServer 호출되는) BlogSvc의 source code 확인 스니펫 :

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 
    }; 
} 
+0

도움이되는 링크지만, 내가 찾고있는 것이 아니 었습니다. 이상적으로 N2와 통합 된 것이 더 필요했습니다. 그래도 고마워. – pauldunlop

0

이것은 내가 사용하는 것입니다. 1 별

N2CMS 5 - - 평가 내용에 대한 내 웹 사이트에 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 
    }