Example #1
0
 public Brand Get(Expression <Func <Brand, bool> > filter)
 {
     using (ReCarProjectContext context = new ReCarProjectContext())
     {
         return(context.Set <Brand>().SingleOrDefault(filter));
     }
 }
Example #2
0
 public List <Brand> GetAll(Expression <Func <Brand, bool> > filter = null)
 {
     using (ReCarProjectContext context = new ReCarProjectContext())
     {
         return(filter == null?context.Set <Brand>().ToList()
                    : context.Set <Brand>().Where(filter).ToList());
     }
 }
Example #3
0
 public void Update(Brand entity)
 {
     using (ReCarProjectContext context = new ReCarProjectContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #4
0
 public void Delete(Brand entity)
 {
     using (ReCarProjectContext context = new ReCarProjectContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Example #5
0
 public void Add(Brand entity)
 {
     using (ReCarProjectContext context = new ReCarProjectContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }