示例#1
0
 // adds new item in the "Studios" table in the database
 public void Add(Studio studio)
 {
     using (studioContext = new MovieStudioContext())
     {
         studioContext.Studios.Add(studio);
         studioContext.SaveChanges();
     }
 }
示例#2
0
 // adds new item in the "Movies" table in the database
 public void Add(Movie movie)
 {
     using (movieContext = new MovieStudioContext())
     {
         movieContext.Movies.Add(movie);
         movieContext.SaveChanges();
     }
 }
示例#3
0
 // deletes item from the database's table "Studios" by given id
 // if item with thethe given id exists
 public void Delete(int id)
 {
     using (studioContext = new MovieStudioContext())
     {
         var studio = studioContext.Studios.Find(id);
         if (studio != null)
         {
             studioContext.Studios.Remove(studio);
             studioContext.SaveChanges();
         }
     }
 }
示例#4
0
 // updates an item from the database's table "Studios" by given object from the class Studio
 // if item with the object's id exists
 public void Update(Studio studio)
 {
     using (studioContext = new MovieStudioContext())
     {
         var item = studioContext.Studios.Find(studio.Id);
         if (item != null)
         {
             studioContext.Entry(item).CurrentValues.SetValues(studio);
             studioContext.SaveChanges();
         }
     }
 }
示例#5
0
 // deletes item from the database's table "Movies" by given id
 // if item with thethe given id exists
 public void Delete(int id)
 {
     using (movieContext = new MovieStudioContext())
     {
         var movie = movieContext.Movies.Find(id);
         if (movie != null)
         {
             movieContext.Movies.Remove(movie);
             movieContext.SaveChanges();
         }
     }
 }
示例#6
0
 // updates an item from the database's table "Movies" by given object from the class Movie
 // if item with the object's id exists
 public void Update(Movie movie)
 {
     using (movieContext = new MovieStudioContext())
     {
         var item = movieContext.Movies.Find(movie.Id);
         if (item != null)
         {
             movieContext.Entry(item).CurrentValues.SetValues(movie);
             movieContext.SaveChanges();
         }
     }
 }