Example #1
0
 public int[] GetAllTabIds()
 {
     using (var context = new ScheduleDbContext())
     {
         return(context.Tabs.Select(t => t.Id).ToArray());
     }
 }
Example #2
0
 public TabDto[] GetAll()
 {
     using (var context = new ScheduleDbContext())
     {
         return(context.Tabs.ToArray());
     }
 }
Example #3
0
 public void Save(TabDto tab)
 {
     using (var context = new ScheduleDbContext())
     {
         context.Tabs.Add(tab);
         context.SaveChanges();
     }
 }
Example #4
0
 public void Delete(int tabId)
 {
     using (var context = new ScheduleDbContext())
     {
         TabDto tab = context.Tabs.Find(tabId);
         context.Tabs.Remove(tab);
         context.SaveChanges();
     }
 }
Example #5
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();
            }
        }
Example #6
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 #7
0
        public (ResultDto Result, AlgorithmSummaryDto[] Summaries) GetByTab(int tabId)
        {
            using (var context = new ScheduleDbContext())
            {
                ResultDto result = context.Results
                                   .Where(r => r.TabId == tabId)
                                   .FirstOrDefault();

                if (result == null)
                {
                    throw new InvalidOperationException("No result for tab available");
                }

                AlgorithmSummaryDto[] summaries = context.AlgorithmSummaries
                                                  .Where(a => a.ResultId == result.Id)
                                                  .ToArray();

                return(Result : result, Summaries : summaries);
            }
        }