/// <summary> /// Update the model /// </summary> /// <param name="m">The model</param> /// <returns>Return the result</returns> public virtual SimpleRsp Update(T m) { var res = new SimpleRsp(); try { _rep.Update(m); } catch (Exception ex) { res.SetError(ex.StackTrace); } return(res); }
public override SimpleRsp Update(Products m) { var res = new SimpleRsp(); var m1 = m.ProductId > 0 ? _rep.Read(m.ProductId) : _rep.Read(m.ProductName); if (m1 == null) { res.SetError("EZ103", "No data."); } else { res = base.Update(m); res.Data = m; } return(res); }
/// <summary> /// Create the model /// </summary> /// <param name="m">The model</param> /// <returns>Return the result</returns> public virtual SimpleRsp Create(T m) { var res = new SimpleRsp(); try { var now = DateTime.Now; _rep.Create(m); } catch (Exception ex) { res.SetError(ex.StackTrace); } return(res); }
// viết hàm Update public SimpleRsp UpdateProduct(Products pro) { var res = new SimpleRsp(); using (var context = new NorthwindContext()) { using (var tran = context.Database.BeginTransaction()) { try { var t = context.Products.Update(pro); context.SaveChanges(); tran.Commit(); } catch (Exception ex) { tran.Rollback(); res.SetError(ex.StackTrace); } } } return(res); }