public bool Check(string login, string password) { using (var dbContext = new CalcContext()) { return(dbContext.Users.Count(u => u.Login == login && u.Password == password) == 1); } }
public User Read(long Id) { using (var db = new CalcContext()) { return(db.Users.FirstOrDefault(u => u.Id == Id)); } }
public IEnumerable <User> GetAll() { using (var dbContext = new CalcContext()) { return(dbContext.Users.Where(u => u.Status == UserStatus.Active)); } }
public IEnumerable <Operation> GetAll() { using (var dbContext = new CalcContext()) { return(dbContext.Operations.ToList()); } }
public void Update(User obj) { using (var db = new CalcContext()) { db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } }
public IEnumerable <Operation> Find(Expression <Func <Operation, bool> > filter) { using (var dbContext = new CalcContext()) { return(dbContext.Operations .Where(filter) .ToList()); } }
public IEnumerable <User> Find(Expression <Func <User, bool> > filter) { using (var dbContext = new CalcContext()) { return(dbContext.Users .Where(u => u.Status == UserStatus.Active) .Where(filter) .ToList()); } }
public User GetByName(string login) { using (var db = new CalcContext()) { var user = db.Users.FirstOrDefault(u => u.Login == login); db.Entry(user).Collection(u => u.OperResults).Load(); return(user); } }
public Operation Read(long Id) { using (var db = new CalcContext()) { var operation = db.Operations.FirstOrDefault(u => u.Id == Id); db.Entry(operation).Collection(u => u.OperResults).Load(); return(operation); } }
public void Delete(long Id) { using (CalcContext db = new CalcContext()) { User delUser = db.Users.FirstOrDefault(c => c.Id == Id); if (delUser != null) { delUser.Status = UserStatus.Dead; } db.SaveChanges(); } }