예제 #1
0
 public bool Check(string login, string password)
 {
     using (var dbContext = new CalcContext())
     {
         return(dbContext.Users.Count(u => u.Login == login && u.Password == password) == 1);
     }
 }
예제 #2
0
 public User Read(long Id)
 {
     using (var db = new CalcContext())
     {
         return(db.Users.FirstOrDefault(u => u.Id == Id));
     }
 }
예제 #3
0
 public IEnumerable <User> GetAll()
 {
     using (var dbContext = new CalcContext())
     {
         return(dbContext.Users.Where(u => u.Status == UserStatus.Active));
     }
 }
예제 #4
0
 public IEnumerable <Operation> GetAll()
 {
     using (var dbContext = new CalcContext())
     {
         return(dbContext.Operations.ToList());
     }
 }
예제 #5
0
 public void Update(User obj)
 {
     using (var db = new CalcContext())
     {
         db.Entry(obj).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
예제 #6
0
 public IEnumerable <Operation> Find(Expression <Func <Operation, bool> > filter)
 {
     using (var dbContext = new CalcContext())
     {
         return(dbContext.Operations
                .Where(filter)
                .ToList());
     }
 }
예제 #7
0
 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());
     }
 }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
 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();
     }
 }