Exemplo n.º 1
0
 public IEnumerable<User> GetAll(int page = 1, int size = 10)
 {
     using(var ctx = new AlfasoftDBContext()){
         return ctx.Set<User>()
             .OrderBy(u=>u.Name)
             .Skip((page-1) * (size))
             .Take(size)
             .ToList();
     }
 }
Exemplo n.º 2
0
 public User RemoveUser(RemoveUserStateModal removeUser)
 {
     using(var ctx = new AlfasoftDBContext()){
         User user = ctx.Users.SingleOrDefault(u => u.Name.Equals(removeUser.Name));
         if(user!=null){
             ctx.Users.Remove(user);
             ctx.SaveChanges();
             return user;
         }
         return null;
     }
 }
Exemplo n.º 3
0
        public User AddUser(NewUserStateModal newUser)
        {
            using(var ctx = new AlfasoftDBContext()){
                if(!ctx.Users.Any(u => u.Name.Equals(newUser.Name) || u.Number == newUser.Id)){
                    var user = newUser.getModel();

                    ctx.Users.Add(user);
                    ctx.SaveChanges();
                    return user;
                }
            }
            return null;
        }