Exemplo n.º 1
0
        /// <summary>
        /// Removes a rating of the given type.
        /// </summary>
        /// <param name="type">The rating type</param>
        /// <param name="modelId">The unique model type</param>
        /// <param name="userId">The user if</param>
        public void RemoveRating(Models.RatingType type, Guid modelId, string userId)
        {
            var rating = session.Get <Models.Rating>(where : r => r.Type == type && r.ModelId == modelId && r.UserId == userId).SingleOrDefault();

            if (rating != null)
            {
                session.Remove <Models.Rating>(rating);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a rating of the given type.
        /// </summary>
        /// <param name="type">The rating type</param>
        /// <param name="modelId">The unique model type</param>
        /// <param name="userId">The user id</param>
        public void AddRating(Models.RatingType type, Guid modelId, string userId)
        {
            var rating = session.Get <Models.Rating>(where : r => r.Type == type && r.ModelId == modelId && r.UserId == userId).SingleOrDefault();

            if (rating == null)
            {
                session.Add <Models.Rating>(new Models.Rating()
                {
                    Type    = type,
                    ModelId = modelId,
                    UserId  = userId
                });
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Adds a rating.
 /// </summary>
 /// <param name="type">The rating type</param>
 /// <param name="id">The model id</param>
 /// <returns>The result</returns>
 private ActionResult AddRating(Models.RatingType type, Guid id)
 {
     if (App.Security.IsAuthenticated())
     {
         using (var api = new Api()) {
             api.Ratings.AddRating(type, id, App.Security.GetUserId());
             return(Json(new {
                 Success = true,
                 Data = Client.Models.RatingsModel.GetByModelId(api, id)
             }, JsonRequestBehavior.AllowGet));
         }
     }
     return(Json(new {
         Success = false
     }, JsonRequestBehavior.AllowGet));
 }