public void Add(Site Site) { using (var context = new WebsitePerfomanceDbContext()) { context.Sites.Add(Site); context.SaveChanges(); } }
public void UpdateSite(List <TestingPage> pagesSite, int id) { using (var context = new WebsitePerfomanceDbContext()) { var currentSite = context.Sites.Include(s => s.Pages.Select(p => p.Speeds)).FirstOrDefault(x => x.Id == id); for (int i = 0; i < pagesSite.Count; i++) { currentSite.Pages[i] = pagesSite[i]; pagesSite[i].Site = currentSite; } context.SaveChanges(); } }