public void saveChanges() { using (var db = new RadioPlayer()) { tbl_mood mood = null; if (!this._isCreateMode) { var id = Convert.ToInt32(this.id.Text); mood = db.tbl_mood.Where(m => m.mood_id == id).FirstOrDefault(); if (mood == null) { this._mainInterface.statusText = $"ERROR: ID '{this.id.Text}' does not exist."; return; } } else { mood = new tbl_mood(); } mood.description = this.description.Text; if (this._isCreateMode) { db.tbl_mood.Add(mood); } db.SaveChanges(); } }
public void deleteItem(object item) { if (item == null) { return; } tbl_mood mood = item as tbl_mood; if (mood == null) { return; } using (var db = new RadioPlayer()) { db.tbl_mood.Remove(db.tbl_mood.Where(m => m.mood_id == mood.mood_id).First()); db.SaveChanges(); } }