Пример #1
0
 /// <summary>
 /// Add a review, and optionally associate it with a restaurant.
 /// </summary>
 /// <param name="review">The review</param>
 /// <param name="restaurant">The restaurant (or null if none)</param>
 public void AddReview(Library.Review review, Library.Restaurant restaurant)
 {
     if (restaurant != null)
     {
         // get the db's version of that restaurant
         // (can't use Find with Include)
         var contextRestaurant = _db.Restaurant.Include(r => r.Review).First(r => r.Id == restaurant.Id);
         restaurant.Reviews.Add(review);
         contextRestaurant.Review.Add(Mapper.Map(review));
     }
     else
     {
         _db.Add(Mapper.Map(review));
     }
 }
Пример #2
0
 /// <summary>
 /// Update a review.
 /// </summary>
 /// <param name="review">The review with changed values</param>
 public void UpdateReview(Library.Review review)
 {
     _db.Entry(_db.Review.Find(review.Id)).CurrentValues.SetValues(Mapper.Map(review));
 }
Пример #3
0
 public static Review Map(Library.Review review) => new Review