示例#1
0
 /// <summary>
 /// Adds a new airplane to the context and saves it to the db
 /// </summary>
 /// <param name="airplane"></param>
 public void CreateAirplane(Airplane airplane)
 {
     using (var context = new AirplanesEntities())
     {
         context.Airplanes.Add(airplane);
         context.SaveChanges();
     }
 }
示例#2
0
 /// <summary>
 /// Creates a country from a country object
 /// </summary>
 /// <param name="name"></param>
 public void CreateCountry(Country country)
 {
     using (var context = new AirplanesEntities())
     {
         context.Countrys.Add(country);
         context.SaveChanges();
     }
 }
示例#3
0
 /// <summary>
 /// removes an airplane by the model
 /// and saves the changes to the db
 /// </summary>
 /// <param name="airplane"></param>
 public void RemoveAirplane(Airplane airplane)
 {
     using (var context = new AirplanesEntities())
     {
         context.Entry(airplane).State = System.Data.Entity.EntityState.Deleted;
         context.Airplanes.Remove(airplane);
         context.SaveChanges();
     }
 }
示例#4
0
 /// <summary>
 /// Removes a country by name
 /// </summary>
 /// <param name="name"></param>
 public void RemoveCountry(Country country)
 {
     using (var context = new AirplanesEntities())
     {
         context.Entry(country).State = System.Data.Entity.EntityState.Deleted;
         context.Countrys.Remove(country);
         context.SaveChanges();
     }
 }