Пример #1
0
 public void Update(Car Entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updatedCar = context.Entry(Entity);
         updatedCar.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #2
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
     }
 }
Пример #3
0
 public void Delete(Car Entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var deletedCar = context.Entry(Entity);
         deletedCar.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Пример #4
0
 public void Add(Color Entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedColor = context.Entry(Entity);
         addedColor.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Пример #5
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();
     }
 }
Пример #6
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
     }
 }
Пример #7
0
 public void Update(Rental entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updateEntity = context.Entry(entity);
         updateEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #8
0
 public void Delete(Rental entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Пример #9
0
 public void Add(Rental entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Пример #10
0
 public void Update(Color entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Пример #11
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
     }
 }
Пример #12
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();
                }
            }
        }