public IHttpActionResult PostRating(Rating data)
        {
            if (data == null)
            {
                return BadRequest();
            }

            Rating rating;
            var userId = User.Identity.Name.GetHashCode();
            var userRatings = _db.Ratings.Where(r => r.UserId == userId);

            if (userRatings.Any())
            {
                //If there exist a rating from this user for this card
                var cardRating = userRatings.Where(r => r.RatingCardName == data.RatingCardName);
                if (cardRating.Any())
                {
                    rating = cardRating.First();
                    rating.RatingValue = data.RatingValue;
                    _db.Entry(rating).State = EntityState.Modified;
                    _db.SaveChanges();
                    return CreatedAtRoute("DefaultApi", new { id = rating.RatingId }, rating);
                }
            }

            rating = new Rating
            {
                RatingValue = data.RatingValue,
                RatingCardName = data.RatingCardName,
                UserId = userId
            };

            //Success
            _db.Ratings.Add(rating);
            _db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = rating.RatingId }, rating);
        }
        public IHttpActionResult PutRating(int id, Rating rating)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != rating.RatingId)
            {
                return BadRequest();
            }

            _db.Entry(rating).State = EntityState.Modified;

            try
            {
                _db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RatingExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }