Beispiel #1
0
 internal static restaurant Create(restaurant i)
 {
     using (var db = new DataClassesDataContext()) {
         db.restaurants.InsertOnSubmit(i);
         db.SubmitChanges();
         return(i);
     }
 }
Beispiel #2
0
 internal static restaurant Update(restaurant i)
 {
     using (var db = new DataClassesDataContext()) {
         var old = db.restaurants.SingleOrDefault(it => it.items_id == i.items_id);
         if (old != null)
         {
             foreach (PropertyInfo property in typeof(restaurant).GetProperties())
             {
                 if (property.Name == "item")
                 {
                     break;
                 }
                 property.SetValue(old, property.GetValue(i, null), null);
             }
         }
         else
         {
             db.restaurants.InsertOnSubmit(i);
         }
         db.SubmitChanges();
         return(i);
     }
 }