public bool Update(StockDepot obj) { //var obj = Db.Set<TEntity>().Find(id); // Db.Entry(obj).State = EntityState.Modified; //if (Db.SaveChanges() > 0) //{ // return true; //} //else //{ // return false; //} try { using (var dbCtx = new ApplicationDbContext()) { //3. Mark entity as modified dbCtx.Entry(obj).State = System.Data.Entity.EntityState.Modified; //4. call SaveChanges dbCtx.SaveChanges(); } } catch { return(false); } return(true); }
public bool Add(StockDepot obj) { Db.Set <StockDepot>().Add(obj); if (Db.SaveChanges() > 0) { return(true); } else { return(false); } }