Exemple #1
0
        public static void insertRating(RatingModel rm)
        {
            // Check if rating for the user already exists
            Rating rating = (from r in _db.Ratings
                             where r.User_ID == rm.userID
                             && r.Route_ID == rm.routeID
                             select r).SingleOrDefault();

            // None exists
            if (rating == null)
            {
                rating = new Rating();
                rating.User_ID = rm.userID;
                rating.Route_ID = rm.routeID;
                rating.Rate = rm.like;
                _db.Ratings.InsertOnSubmit(rating);
            }
            else
            {
                rating.Rate = rm.like;
            }

            _db.SubmitChanges();
        }
Exemple #2
0
        public PartialViewResult RatingVote(int id, bool vote)
        {
            Guid userId = (Guid)Membership.GetUser().ProviderUserKey;
            RatingModel rm = new RatingModel(userId, id, vote);

            RatingModel.insertRating(rm);

            RouteModel routem = new RouteModel(id);
            return PartialView("Routes/_ListRoutesElement", routem);
        }