Beispiel #1
0
 public virtual Product GetById(int id)
 {
     using (db = new DemoFPTEntities())
     {
         return(db.Products.FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #2
0
 public override void Delete(int id)
 {
     using (var db = new DemoFPTEntities())
     {
         var product = db.Products.SingleOrDefault(x => x.Id == id);
         db.Products.Remove(product);
         db.SaveChanges();
     }
 }
Beispiel #3
0
 public override void Insert(Product product)
 {
     using (var db = new DemoFPTEntities())
     {
         product.CreatedAt = DateTime.Now;
         product.UpdateAt  = DateTime.Now;
         db.Products.Add(product);
         db.SaveChanges();
     }
 }
Beispiel #4
0
        public override void Update(Product product)
        {
            using (var db = new DemoFPTEntities())
            {
                var _product = db.Products.Find(product.Id);
                _product.Name        = product.Name;
                _product.Manufacture = product.Manufacture;
                _product.CreatedBy   = product.CreatedBy;
                _product.UpdateAt    = DateTime.Now;
                _product.UpdateBy    = product.UpdateBy;
                _product.Deleted     = product.Deleted;
                _product.Active      = product.Active;
                _product.Description = product.Description;

                db.SaveChanges();
            }
        }