Ejemplo n.º 1
0
 public List <Campground> GetAllCampgrounds()
 {
     using (var campgroundDbContext = new CampgroundDbContext())
     {
         return(campgroundDbContext.Campgrounds.ToList());
     }
 }
Ejemplo n.º 2
0
 public Campground GetCampgroundById(int id)
 {
     using (var campgroundDbContext = new CampgroundDbContext())
     {
         return(campgroundDbContext.Campgrounds.Find(id));
     }
 }
Ejemplo n.º 3
0
 public Campground UpdateCampground(Campground campground)
 {
     using (var campgroundDbContext = new CampgroundDbContext())
     {
         campgroundDbContext.Campgrounds.Update(campground);
         campgroundDbContext.SaveChanges();
         return(campground);
     }
 }
Ejemplo n.º 4
0
 public void DeleteCampground(int id)
 {
     using (var campgroundDbContext = new CampgroundDbContext())
     {
         var deletedCampground = GetCampgroundById(id);
         campgroundDbContext.Remove(deletedCampground);
         campgroundDbContext.SaveChanges();
     }
 }