public void Insert(People obj) { using (var ctx = new HaveLunchContext()) { ctx.Peoples.Add(obj); ctx.SaveChanges(); } }
public void Delete(int id) { using (var ctx = new HaveLunchContext()) { People people = ctx.Peoples.FirstOrDefault((p) => p.Id.Equals(id)); ctx.Peoples.Remove(people); 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))); } }