public T Delete(T entity) { using (var db = new DbTodosContext()) { var teamMemberDb = db.GetDbSet <T>(dbSet).First(t => t.Id == entity.Id); db.GetDbSet <T>(dbSet).Remove(teamMemberDb); db.SaveChanges(); return(teamMemberDb); } }
public virtual List <T> GetList(Specification <T> specification = null) { using (var db = new DbTodosContext()) { specification = specification ?? new AllRecordsSpecification <T>(); return(db.GetDbSet <T>(dbSet).Where(specification.ToExpression()).ToList()); } }
public virtual T Get(Specification <T> specification = null) { using (var db = new DbTodosContext()) { specification = specification ?? new AllRecordsSpecification <T>(); return(db.GetDbSet <T>(dbSet).FirstOrDefault(specification.ToExpression())); } }
public virtual T Update(T entity) { using (var db = new DbTodosContext()) { var teamMemberDb = db.GetDbSet <T>(dbSet).First(t => t.Id == entity.Id); ReflectionUtil.CopyValues <T>(teamMemberDb, entity); db.SaveChanges(); return(teamMemberDb); } }
public virtual T Add(T entity) { T toReturn = default(T); using (var db = new DbTodosContext()) { var set = db.GetDbSet <T>(dbSet); toReturn = set.Add(entity); db.SaveChanges(); } return(toReturn); }