public void Post([FromBody] Review review) { review.City = review.City.ToUpper(); review.Country = review.Country.ToUpper(); _db.Reviews.Add(review); _db.SaveChanges(); }
public void Post([FromBody] Review review) { _db.Review.Add(review); Destination destination = _db.Destination.FirstOrDefault(dest => dest.DestinationId == review.DestinationId); destination.Reviews.Add(review); destination.Rating = (destination.Reviews.Sum(dest => Convert.ToInt32(dest.Rating)) / destination.Reviews.Count); _db.Entry(destination).State = EntityState.Modified; _db.SaveChanges(); }
public void Post([FromBody] Review review) { _db.Reviews.Add(review); var thisDestination = _db.Destinations .Include(destination => destination.Reviews) .FirstOrDefault(x => x.DestinationId == review.DestinationId); thisDestination.GetAvgRating(); _db.SaveChanges(); }
public void Post([FromBody] Review review) { List <Review> reviews = _db.Reviews.Where(rev => rev.DestinationId == review.DestinationId).ToList(); double rating = review.Rating; int j = 1; foreach (Review rev in reviews) { rating += rev.Rating; j++; } Destination currentDestination = _db.Destinations.FirstOrDefault(dest => dest.DestinationId == review.DestinationId); currentDestination.Rating = rating / j; _db.Entry(currentDestination).State = EntityState.Modified; _db.Reviews.Add(review); _db.SaveChanges(); }
public void Post([FromBody] Review review) { _db.Reviews.Add(review); _db.SaveChanges(); }
public void Post([FromBody] City city) { _db.Cities.Add(city); _db.SaveChanges(); }
public void Post([FromBody] Destination destination) { _db.Destination.Add(destination); _db.SaveChanges(); }
public void Post([FromBody] Destination theDestination) { _db.Destinations.Add(theDestination); _db.SaveChanges(); }
public void Post([FromBody] Packlist packlist) { _db.Packlists.Add(packlist); _db.SaveChanges(); }
public void Post([FromBody] Place place) { _db.Places.Add(place); _db.SaveChanges(); }
public void Post([FromBody] Location location) { _db.Locations.Add(location); _db.SaveChanges(); }