예제 #1
0
 public Rental Get(Expression <Func <Rental, bool> > filter)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         return(context.Set <Rental>().SingleOrDefault(filter));
     }
 }
예제 #2
0
 public Car Get(Expression <Func <Car, bool> > filter)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         return(context.Set <Car>().SingleOrDefault());
     }
 }
예제 #3
0
 public List <Brand> GetAll(Expression <Func <Brand, bool> > filter = null)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         return(filter == null?context.Set <Brand>().ToList() : context.Set <Brand>().Where(filter).ToList());
     }
 }
예제 #4
0
 public Brand Get(Expression <Func <Brand, bool> > filter)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         return(context.Set <Brand>().SingleOrDefault(filter));
     }
 }
예제 #5
0
 public void Update(Car Entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updatedCar = context.Entry(Entity);
         updatedCar.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #6
0
 public void Delete(Car Entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var deletedCar = context.Entry(Entity);
         deletedCar.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
예제 #7
0
 public void Add(Color Entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedColor = context.Entry(Entity);
         addedColor.State = EntityState.Added;
         context.SaveChanges();
     }
 }
예제 #8
0
 public void Update(Car entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updatedEntity = context.Entry(entity);  //ref. yakala
         updatedEntity.State = EntityState.Modified; //o aslında güncel. nesne
         context.SaveChanges();                      //gün
     }
 }
예제 #9
0
 public void Delete(Car entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var deletedEntity = context.Entry(entity); //ref. yakala
         deletedEntity.State = EntityState.Deleted; //o aslında eklenecek nesne
         context.SaveChanges();                     //ekle
     }
 }
예제 #10
0
 public void Update(Car entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updatedEntity = context.Entry(entity); //gelen parametredeki özelliklerde olan nesneyi eşleştir
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #11
0
 public void Update(Rental entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updateEntity = context.Entry(entity);
         updateEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #12
0
 public void Delete(Rental entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
예제 #13
0
 public void Add(Rental entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
예제 #14
0
 public void Update(Color entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
예제 #15
0
 public void Add(Car entity)
 {
     //IDisposable pattern implementation of c#
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedEntity = context.Entry(entity); //ref. yakala
         addedEntity.State = EntityState.Added;   //o aslında eklenecek nesne
         context.SaveChanges();                   //ekle
     }
 }
예제 #16
0
        public void Add(Car Entity)
        {
            using (ReCapProjectContext context = new ReCapProjectContext())
            {
                var addedCar = context.Entry(Entity);

                if (addedCar.Entity.Description.Length >= 2 && addedCar.Entity.DailyPrice > 0)
                {
                    Console.WriteLine("Araba açıklaması en az 2 karakter olmalıdır.");
                }
                else if (addedCar.Entity.Description.Length >= 2 && addedCar.Entity.DailyPrice < 0)
                {
                    Console.WriteLine("Araba günlük fiyatı 0 dan büyük olmalıdır.");
                }
                else
                {
                    addedCar.State = EntityState.Added;
                    context.SaveChanges();
                }
            }
        }