Example #1
0
        public void Save(ResultDto result, AlgorithmSummaryDto[] summaries)
        {
            using (var context = new ScheduleDbContext())
            {
                context.Results.Add(result);
                context.SaveChanges();

                foreach (var summary in summaries)
                {
                    summary.ResultId = result.Id;
                    context.AlgorithmSummaries.Add(summary);
                }

                context.SaveChanges();
            }
        }
Example #2
0
 public void Save(TabDto tab)
 {
     using (var context = new ScheduleDbContext())
     {
         context.Tabs.Add(tab);
         context.SaveChanges();
     }
 }
Example #3
0
 public void Delete(int tabId)
 {
     using (var context = new ScheduleDbContext())
     {
         TabDto tab = context.Tabs.Find(tabId);
         context.Tabs.Remove(tab);
         context.SaveChanges();
     }
 }
Example #4
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();
            }
        }