public void AddDeveloper(string Developer_Name, string Official_Site, bool Indie) { var _context = new db_MinligareevMAContext(); Developers developer = new Developers(); developer.Developer_Name = Developer_Name; developer.Official_Site = Official_Site; developer.Indie = Indie; try { _context.Developers.Add(developer); _context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Warning"); Logging(ex.Message, ex.StackTrace); } }
public List <Developers> GetDevelopersEF() { List <Developers> Developer = new List <Developers>(); foreach (var el in _context.Developers) { Developers d = new Developers(); d.ID_Developer = el.ID_Developer; d.Developer_Name = el.Developer_Name; d.Official_Site = el.Official_Site; d.Indie = el.Indie; Developer.Add(d); } Developers All = new Developers(); All.ID_Developer = -1; All.Developer_Name = "All Developers"; Developer.Insert(0, All); return(Developer.ToList()); }
public List <Developers> GetDevelopersEF_WithoutAll(bool?Active) { List <Developers> resDeveloper = new List <Developers>(); var dev = _context.Developers.Where(o => o.ID_Developer >= 0); if (Active.HasValue) { dev = dev.Where(o => o.Indie == Active); } //if (idGame.HasValue) dev = dev.Where(o => o.Games.Where(q => q.ID_Game == idGame).Count() > 0); foreach (var el in dev) { Developers d = new Developers(); d.ID_Developer = el.ID_Developer; d.Developer_Name = el.Developer_Name; d.Official_Site = el.Official_Site; d.Indie = el.Indie; resDeveloper.Add(d); } return(resDeveloper.ToList()); }
public void DeleteDeveloper(int ID) { try { foreach (var el in _context.Games) { if (el.ID_Developer == ID) { _context.Games.Remove(el); } } Developers developer = (from d in _context.Developers where d.ID_Developer == ID select d).SingleOrDefault(); _context.Developers.Remove(developer); _context.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Warning"); Logging(ex.Message, ex.StackTrace); } }