Exemple #1
0
 public Color Get(Expression <Func <Color, bool> > filter)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         return(context.Set <Color>().SingleOrDefault(filter));
     }
 }
Exemple #2
0
 public List <Color> GetAll(Expression <Func <Color, bool> > filter = null)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         return(filter == null?context.Set <Color>().ToList() : context.Set <Color>().Where(filter).ToList());
     }
 }
Exemple #3
0
 public Brand Get(Expression <Func <Brand, bool> > filter)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         return(context.Set <Brand>().SingleOrDefault(filter));
     }
 }
Exemple #4
0
 public void Update(Color entity)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #5
0
 public void Delete(Color entity)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemple #6
0
 public void Add(Color entity)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Exemple #7
0
 public void Add(Brand entity)
 {
     using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = Microsoft.EntityFrameworkCore.EntityState.Added;
         context.SaveChanges();
     }
 }
 public void Add(Car entity)
 {
     if (entity.Description.Length > 2 && entity.DailyPrices > 0)
     {
         using (ReCapDemoDbContex1 context = new ReCapDemoDbContex1())
         {
             var addedEntity = context.Entry(entity);
             addedEntity.State = EntityState.Added;
             context.SaveChanges();
         }
     }
     else
     {
         Console.WriteLine("Girdiginiz değerlere uyan bir araç olamaz.");
     }
 }