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