public Milestone CreateOrUpdate(Milestone entity) { try { _context.Entry(entity).State = entity.Id == 0 ? EntityState.Added: EntityState.Modified; _context.SaveChanges(); return(entity); } catch (Exception ex) { throw new Exception("Failed."); } }
public bool Update(T entity, bool autoSave = true) { _dbContext.Attach(entity); _dbContext.Entry(entity).State = EntityState.Modified; if (autoSave) { return(Save()); } else { return(false); } }