public void Insert(People obj) { using (var ctx = new HaveLunchContext()) { ctx.Peoples.Add(obj); ctx.SaveChanges(); } }
public void Update(People obj) { try { using (var ctx = new HaveLunchContext()) { People people = ctx.Peoples.FirstOrDefault((p) => p.Id.Equals(obj.Id)); people.Places = obj.Places; people.Name = obj.Name; ctx.SaveChanges(); } } catch (Exception ex) { throw new ArgumentNullException(string.Format("We Can't do this right now", nameof(ex.Message))); } }