Example #1
0
 public void Dispose()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         context.Dispose();
     }
 }
Example #2
0
 public int Commit()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.SaveChanges());
     }
 }
Example #3
0
 public IEnumerable <Skill> GetAll()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Skills.AsNoTracking().ToList());
     }
 }
Example #4
0
 public IEnumerable <Experience> GetAll()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Experience.AsNoTracking().ToList());
     }
 }
Example #5
0
 public Education Read(int id)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Education.AsNoTracking().SingleOrDefault(e => e.Id == id));
     }
 }
Example #6
0
 public Skill Read(int id)
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Skills.AsNoTracking().SingleOrDefault(e => e.Id == id));
     }
 }
Example #7
0
 public IEnumerable <Education> GetAll()
 {
     using (var context = new PortfolioDbContext(_db))
     {
         return(context.Education.AsNoTracking().ToList());
     }
 }
Example #8
0
 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);
     }
 }
Example #9
0
 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);
     }
 }
Example #10
0
 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);
     }
 }
Example #11
0
 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);
     }
 }
Example #12
0
 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);
     }
 }
Example #13
0
 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);
     }
 }
Example #14
0
 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);
     }
 }
Example #15
0
 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);
     }
 }
Example #16
0
 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);
     }
 }
Example #17
0
 public void Delete(Experience experience)
 {
     if (experience != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Experience.Remove(experience);
             context.SaveChanges();
         }
     }
 }
Example #18
0
 public void Delete(Education education)
 {
     if (education != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Education.Remove(education);
             context.SaveChanges();
         }
     }
 }
Example #19
0
 public void Delete(Skill skill)
 {
     if (skill != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Skills.Remove(skill);
             context.SaveChanges();
         }
     }
 }
Example #20
0
 public void Delete(Project project)
 {
     if (project != null)
     {
         using (var context = new PortfolioDbContext(_db))
         {
             context.Projects.Remove(project);
             context.SaveChanges();
         }
     }
 }