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; } }
public long insert(Product entity) { try { entity.CreatedAt = DateTime.Now; db.Products.Add(entity); db.SaveChanges(); return entity.id; } catch { return -1; } }