コード例 #1
0
 public bool update(Product entity)
 {
     try
     {
         Product p = db.Products.Find(entity.id);
         p.Category = entity.Category;
         p.CreatedBy = entity.CreatedBy;
         p.Description = entity.Description;
         p.ModifiedAt = DateTime.Now;
         p.ModifiedBy = entity.ModifiedBy;
         p.MoreImages = entity.MoreImages;
         p.Name = entity.Name;
         p.Price = entity.Price;
         p.Promotion = entity.Promotion;
         p.PromotionPrice = entity.PromotionPrice;
         p.Quantity = entity.Quantity;
         p.ShowOnHome = entity.ShowOnHome;
         p.Status = entity.Status;
         p.Thumbnail = entity.Thumbnail;
         db.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #2
0
 public long insert(Product entity)
 {
     try
     {
         entity.CreatedAt = DateTime.Now;
         db.Products.Add(entity);
         db.SaveChanges();
         return entity.id;
     }
     catch
     {
         return -1;
     }
 }