public void Save(string name, string screenshot = "") { EcommercePlatformDataContext db = new EcommercePlatformDataContext(); Theme theme = new Theme(); if (this.ID > 0) theme = db.Themes.Where(x => x.ID.Equals(this.ID)).FirstOrDefault(); else theme = new Theme(); theme.name = name; theme.screenshot = (string.IsNullOrWhiteSpace(screenshot)) ? null : screenshot; if (theme.ID == 0) { theme.dateAdded = DateTime.UtcNow; theme.active = false; db.Themes.InsertOnSubmit(theme); } db.SubmitChanges(); this.ID = theme.ID; }
public Theme Get(int id = 0) { Theme theme = new Theme(); EcommercePlatformDataContext db = new EcommercePlatformDataContext(); theme = db.Themes.Where(x => x.ID.Equals(id)).FirstOrDefault(); return theme; }
public Theme Duplicate(int id) { EcommercePlatformDataContext db = new EcommercePlatformDataContext(); Theme theme = db.Themes.Where(x => x.ID.Equals(id)).FirstOrDefault(); Theme newtheme = new Theme(); if (theme != null && theme.ID > 0) { newtheme = new Theme { screenshot = theme.screenshot, name = "Copy of " + theme.name, active = false, dateAdded = DateTime.UtcNow }; db.Themes.InsertOnSubmit(newtheme); db.SubmitChanges(); foreach (ThemeFile file in theme.ThemeFiles) { file.Duplicate(newtheme.ID); } } return newtheme; }
partial void DeleteTheme(Theme instance);
partial void UpdateTheme(Theme instance);
partial void InsertTheme(Theme instance);