public void Dispose() { using (var context = new PortfolioDbContext(_db)) { context.Dispose(); } }
public int Commit() { using (var context = new PortfolioDbContext(_db)) { return(context.SaveChanges()); } }
public IEnumerable <Skill> GetAll() { using (var context = new PortfolioDbContext(_db)) { return(context.Skills.AsNoTracking().ToList()); } }
public IEnumerable <Experience> GetAll() { using (var context = new PortfolioDbContext(_db)) { return(context.Experience.AsNoTracking().ToList()); } }
public Education Read(int id) { using (var context = new PortfolioDbContext(_db)) { return(context.Education.AsNoTracking().SingleOrDefault(e => e.Id == id)); } }
public Skill Read(int id) { using (var context = new PortfolioDbContext(_db)) { return(context.Skills.AsNoTracking().SingleOrDefault(e => e.Id == id)); } }
public IEnumerable <Education> GetAll() { using (var context = new PortfolioDbContext(_db)) { return(context.Education.AsNoTracking().ToList()); } }
public Experience Read(int id) { using (var context = new PortfolioDbContext(_db)) { var experience = context.Experience.AsNoTracking().SingleOrDefault(e => e.Id == id); //WITH NO LOCK return(experience); } }
public Project Create(Project project) { using (var context = new PortfolioDbContext(_db)) { project.Id = context.Projects.Max(p => p.Id) + 1; context.Projects.Add(project); context.SaveChanges(); return(project); } }
public Experience Create(Experience experience) { using (var context = new PortfolioDbContext(_db)) { experience.Id = context.Experience.Max(e => e.Id) + 1; context.Experience.Add(experience); context.SaveChanges(); return(experience); } }
public Education Update(Education education) { using (var context = new PortfolioDbContext(_db)) { var entity = context.Education.Attach(education); entity.State = EntityState.Modified; context.SaveChanges(); return(entity.Entity); } }
public Project Update(Project project) { using (var context = new PortfolioDbContext(_db)) { var entity = context.Projects.Attach(project); entity.State = EntityState.Modified; context.SaveChanges(); return(entity.Entity); } }
public Experience Update(Experience experience) { using (var context = new PortfolioDbContext(_db)) { var entity = context.Experience.Attach(experience); entity.State = EntityState.Modified; context.SaveChanges(); return(entity.Entity); } }
public Skill Update(Skill skill) { using (var context = new PortfolioDbContext(_db)) { var entity = context.Skills.Attach(skill); entity.State = EntityState.Modified; context.SaveChanges(); return(entity.Entity); } }
public Education Create(Education education) { using (var context = new PortfolioDbContext(_db)) { education.Id = context.Education.Max(e => e.Id) + 1; context.Education.Add(education); context.SaveChanges(); return(education); } }
public Skill Create(Skill skill) { using (var context = new PortfolioDbContext(_db)) { skill.Id = context.Skills.Max(s => s.Id) + 1; context.Skills.Add(skill); context.SaveChanges(); return(skill); } }
public void Delete(Experience experience) { if (experience != null) { using (var context = new PortfolioDbContext(_db)) { context.Experience.Remove(experience); context.SaveChanges(); } } }
public void Delete(Education education) { if (education != null) { using (var context = new PortfolioDbContext(_db)) { context.Education.Remove(education); context.SaveChanges(); } } }
public void Delete(Skill skill) { if (skill != null) { using (var context = new PortfolioDbContext(_db)) { context.Skills.Remove(skill); context.SaveChanges(); } } }
public void Delete(Project project) { if (project != null) { using (var context = new PortfolioDbContext(_db)) { context.Projects.Remove(project); context.SaveChanges(); } } }