示例#1
0
        public async Task AddPlace(Place place)
        {
            await dbContext.Places.AddAsync(place);

            //Console.WriteLine(newlyAdded.Entity.id);
            await dbContext.SaveChangesAsync();

            //return newlyAdded.Entity;
        }
示例#2
0
        public async Task <Review> AddReview(Review review, long placeId)
        {
            Place myPlace = await dbContext.Places.FirstOrDefaultAsync(p => p.id == placeId);

            myPlace.reviews.Add(review);                                                // Add review to the place's list of reviews
            EntityEntry <Review> newlyAdded = await dbContext.Reviews.AddAsync(review); // Add review to the table Review

            await dbContext.SaveChangesAsync();

            return(newlyAdded.Entity);
        }
示例#3
0
        /*public Task<Review> AddPlaceReview(long placeId, Review review)
         * {
         *  throw new System.NotImplementedException();
         * }*/

        public async Task BanUser(long userId)
        {
            User myUser = dbContext.Users.FirstOrDefault(u => u.id == userId);

            myUser.auth = 0;
            await dbContext.UserReports.Where(r => r.reportedItem.id == userId).ForEachAsync(r => r.resolved = true);

            await dbContext.SaveChangesAsync();
        }