public void Delete(T entity)
 {
     if (entity.GetType().GetProperty("IsDelete") != null)
     {
         T _entity = entity;
         _entity.GetType().GetProperty("IsDelete").SetValue(_entity, true);
         this.Update(_entity);
     }
     else
     {
         DbEntityEntry dbEntityEntry = _context.Entry(entity);
         if (dbEntityEntry.State != EntityState.Deleted)
         {
             dbEntityEntry.State = EntityState.Deleted;
         }
         else
         {
             _dbSet.Attach(entity);
             _dbSet.Remove(entity);
         }
     }
 }
示例#2
0
        public ActionResult Edit(int id, FormCollection collection, Urunler urn, HttpPostedFileBase resim)
        {
            try
            {
                string yol = ResimKaydet(resim);
                urn.UrunResimYol = "image/buyuk/" + yol;
                urn.kUrunResim   = "image/kck/" + yol;
                urn.kkUrunResim  = "image/kkck/" + yol;
                // TODO: Add update logic here
                db.Entry(urn).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }