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