public async Task<int> Save(T_Customer_Product model) { using (db = new KBLDataContext()) { var entity = from t in db.CustomerProducts where t.Pid == model.Pid select t; T_Customer_Product _prodcut = await entity.FirstOrDefaultAsync(); if (_prodcut == null) { db.CustomerProducts.Add(model); } else { _prodcut.Name = model.Name; _prodcut.Price = model.Price; _prodcut.Quantity = model.Quantity; _prodcut.SaleAmount = model.SaleAmount; _prodcut.Vp = model.Vp; _prodcut.PurchasingDate = model.PurchasingDate; _prodcut.GeneratintVpDate = model.GeneratintVpDate; db.Entry(_prodcut).State = EntityState.Modified; } return await db.SaveChangesAsync(); } }
public async Task<object> ProductSave(T_Customer_Product model) { object data = await T_Customer_BLL.SaveCustomerProduct(model); return Ok(new { statusCode = 200, result = data }); }
/// <summary> /// 保存客户产品模型 /// </summary> /// <param name="model"></param> /// <returns></returns> public static async Task<int> SaveCustomerProduct(T_Customer_Product model) { using (T_Customer_Product_Entities dao = new T_Customer_Product_Entities()) { return await dao.Save(model); } }