예제 #1
0
 public void Save(TabDto tab)
 {
     using (var context = new ScheduleDbContext())
     {
         context.Tabs.Add(tab);
         context.SaveChanges();
     }
 }
예제 #2
0
 public void Delete(int tabId)
 {
     using (var context = new ScheduleDbContext())
     {
         TabDto tab = context.Tabs.Find(tabId);
         context.Tabs.Remove(tab);
         context.SaveChanges();
     }
 }
예제 #3
0
        public void Update(TabDto tab)
        {
            using (var context = new ScheduleDbContext())
            {
                TabDto targetTab = context.Tabs.Find(tab.Id);
                if (targetTab == null)
                {
                    throw new InvalidOperationException($"Tab {tab.Id} does not exist");
                }

                context.Entry(targetTab).CurrentValues.SetValues(tab);
                context.SaveChanges();
            }
        }