Exemplo n.º 1
0
 // GET api/rating/5
 public IEnumerable<Rating> Get(int id)
 {
     List<UserRating> ratings = WorldDestinationsRepository.WorldDestinations.UserRatings.ToList().Where(m=>m.PlaceID==id).ToList() ;
     List<Rating> ratingss = new List<Rating>();
     Rating rating;
     foreach (UserRating r in ratings)
     {
         rating = new Rating();
         rating.UserName = r.UserName;
         rating.RatingID = r.Id;
         rating.Comment = r.Comment;
         rating.Ratingg =(short) r.Rating;
         ratingss.Add(rating);
     }
     return ratingss;
 }
Exemplo n.º 2
0
        // POST api/rating
        public string Post(Rating rating)
        {
            UserRating newRating = new UserRating();
            newRating.Comment = rating.Comment;
            newRating.PlaceID = rating.PlaceID;
            newRating.Rating = rating.Ratingg;
            newRating.UserName = rating.UserName;

            WorldDestinationsRepository.WorldDestinations.UserRatings.Add(newRating);
            try
            {
                WorldDestinationsRepository.WorldDestinations.SaveChanges();
                return "YES";
            }
            catch (Exception e)
            {
                return "NO";
            }
        }