Exemple #1
0
        public void TestPrepare()
        {
            User user = new User();

            user.Username = "******";
            user.Password = "******";

            IUserDal dal =new UserDal();
            User returnedUser = dal.ValidateUser(user);
            prepareDto = new PrepareUserDto();
            UserDto dto = prepareDto.Prepare(returnedUser);

            Console.Write(dto.Name);

            String[] mem = dto.Memberships;

            for (int count = 0; count < mem.Length; count++)
            {
                Console.Write(mem[count]);
            }

            for (int i = 0; i < dto.Tokens.Count; i++)
            {
                Console.WriteLine(dto.Tokens[i]);
            }

            Assert.IsNotNull(dto,"Should not be null");
        }
Exemple #2
0
 public void TestFindById()
 {
     IUserDal uDal = new UserDal();
     User user = uDal.FindById(20);
     Console.WriteLine(user.Name);
     Assert.IsNotNull(user);
 }
Exemple #3
0
        public User GetUserById(int id)
        {
            IUserDal userDal = new UserDal();
            User user = userDal.FindById(id);

            return user;
        }
Exemple #4
0
        public User GetUser(string username, string password)
        {
            User user = new User();

            user.Username = username;
            user.Password = password;

            IUserDal userDal = new UserDal();

            return user;
        }
Exemple #5
0
 public IList<UserBookRequest> UserSearch(String searchString)
 {
     try
     {
         IUserDal userDal = new UserDal();
         IList<UserBookRequest> returnedUserList = userDal.SearchUser(searchString);
         return returnedUserList;
     }
     catch (Exception e)
     {
         Console.WriteLine("Error in userService,userSearch()");
         Console.Write(e.ToString());
         return null;
     }
 }
Exemple #6
0
        public Boolean Create(User user)
        {
            try
            {
                IList<User> userlist = new List<User>();
                userlist.Add(user);

                IUserDal userDal = new UserDal();
                Boolean status = userDal.CreateNewUser(userlist);
                return status;
            }

            catch (Exception e)
            {
                Console.WriteLine("Error at UserService , CreateNewUser");
                Console.Write(e.ToString());
                return false;
            }
        }
Exemple #7
0
        public UserDto ValidateUser(string username, string password)
        {
            User user = new User();

            user.Username = username;
            user.Password = password;

            IUserDal userdal = new UserDal();
            User returnedUser = userdal.ValidateUser(user);

            if (returnedUser == null)
            {
                return null;
            }
            else
            {
                IPrepareUserDto prepareUserDto = new PrepareUserDto();
                UserDto userdto = prepareUserDto.Prepare(returnedUser);
                return userdto;
            }
        }
Exemple #8
0
        //       [TestMethod]
        public void TestUserDal()
        {
            UserDal uDal = new UserDal();

            User user = new User();

            user.Username = "******";
            user.Password = "******";

            User u = uDal.ValidateUser(user);
            IList<Membership> membership = u.Memberships;
            IList<Role> role = u.Roles;
            IList<Token> token = role[0].Tokens;

            Membership m = membership[0];
            Role r = role[0];
            Token t = token[0];

            Console.WriteLine("Membership : "+m.Name);
            Console.WriteLine("Role : "+r.Name);
            Console.WriteLine("Token : "+t.Name);

            //      Assert.AreEqual(1,uDal.Create(user));
        }