public Viwer(int id) { InitializeComponent(); location = DB.Instance.locations.Find(id); betterTextBox1.Text = location.name; saveondatabase = true; }
private void materialButton2_Click(object sender, EventArgs e) { if (saveondatabase) { location.name = betterTextBox1.Text; location.updated_at = DateTime.Now; location.created_at = DateTime.Now; location.admin_id = INFO.admin_id; DB.Instance.SaveChanges(); } else { var newcate = new Model.location() { name = betterTextBox1.Text, created_at = DateTime.Now, updated_at = DateTime.Now, admin_id = INFO.admin_id, }; DB.Instance.locations.Add(newcate); DB.Instance.SaveChanges(); saveondatabase = true; } }