コード例 #1
0
ファイル: DBUtility.cs プロジェクト: smajko31/Zelp
        /// <summary>
        /// Edit restaurant based on edited fields
        /// </summary>
        /// <param name="r">Restaurant with updated info</param>
        /// <param name="restaurantId">Restaurant id</param>
        public void EditRestaurant(Restaurant r, int restaurantId)
        {
            using (var db = new RestaurantsEntities())
            {
                Restaurant res = GetRestaurantModels().SingleOrDefault(x => x.id == restaurantId);
                res.Name    = r.Name;
                res.Address = r.Address;

                db.Restaurants.Attach(res);
                db.Entry(res).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
コード例 #2
0
ファイル: DBUtility.cs プロジェクト: smajko31/Zelp
        /// <summary>
        /// Edit review based on changed fields
        /// </summary>
        /// <param name="r">Review with updated info</param>
        /// <param name="reviewId">Review id</param>
        public void EditReview(Review r, int reviewId)
        {
            using (var db = new RestaurantsEntities())
            {
                Review rev = GetReviewModels().SingleOrDefault(x => x.ReviewId == reviewId);
                rev.Name    = r.Name;
                rev.Rating  = r.Rating;
                rev.Summary = r.Summary;

                db.Reviews.Attach(rev);
                db.Entry(rev).State = EntityState.Modified;
                db.SaveChanges();
            }
        }