예제 #1
0
 public void Insert(People obj)
 {
     using (var ctx = new HaveLunchContext())
     {
         ctx.Peoples.Add(obj);
         ctx.SaveChanges();
     }
 }
예제 #2
0
 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();
     }
 }
예제 #3
0
        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)));
            }
        }