Ejemplo n.º 1
0
        public UserDTO AddUser(NewUserDTO newUserDTO)
        {
            var user = DtoFactory.NewUserDtoToUserModel(newUserDTO);

            db.Users.AddEntity(user);
            db.Save();
            var id           = user.Id;
            var newUserModel = db.Users.GetUserById(id);

            return(DtoFactory.UserModelToUserDTO(newUserModel));
        }
Ejemplo n.º 2
0
        public IEnumerable <UserDTO> Search(string key)
        {
            var users = db.Users.Search(key);
            var dtos  = new List <UserDTO>();

            foreach (var user in users)
            {
                dtos.Add(DtoFactory.UserModelToUserDTO(user));
            }

            return(dtos);
        }
Ejemplo n.º 3
0
        public IEnumerable <UserDTO> GetMentors()
        {
            var mentorModels = db.Users.GetMentors();

            if (mentorModels == null)
            {
                return(null);
            }

            var mentorsDtos = new List <UserDTO>();

            foreach (var item in mentorModels)
            {
                mentorsDtos.Add(DtoFactory.UserModelToUserDTO(item));
            }
            return(mentorsDtos);
        }
Ejemplo n.º 4
0
        public IEnumerable <UserDTO> GetAllStudents()
        {
            var studentModels = db.Users.GetStudents();

            if (studentModels == null)
            {
                return(null);
            }

            var studentsDtos = new List <UserDTO>();

            foreach (var item in studentModels)
            {
                studentsDtos.Add(DtoFactory.UserModelToUserDTO(item));
            }
            return(studentsDtos);
        }
Ejemplo n.º 5
0
        public IEnumerable <UserDTO> GetStudentsNotInCurrentGroup(int groupId)
        {
            var studentsNotInCurrentGroup = db.Users.GetStudentsNotInGroup(groupId);

            if (studentsNotInCurrentGroup == null)
            {
                return(null);
            }
            var studentsDtos = new List <UserDTO>();

            foreach (var student in studentsNotInCurrentGroup)
            {
                studentsDtos.Add(DtoFactory.UserModelToUserDTO(student));
            }

            return(studentsDtos);
        }
Ejemplo n.º 6
0
        public IEnumerable <UserDTO> GetUsersFromGroup(int groupId)
        {
            var userModelsInGroup = db.Users.GetStudentsByGroupId(groupId);

            if (userModelsInGroup == null)
            {
                return(null);
            }

            var usersInGroup = new List <UserDTO>();

            foreach (var item in userModelsInGroup)
            {
                usersInGroup.Add(DtoFactory.UserModelToUserDTO(item));
            }

            return(usersInGroup);
        }
Ejemplo n.º 7
0
        public IEnumerable <UserDTO> GetAllUsers()
        {
            var users = db.Users.GetAllUsers();

            if (users == null)
            {
                return(null);
            }

            var dtos = new List <UserDTO>();

            foreach (var user in users)
            {
                dtos.Add(DtoFactory.UserModelToUserDTO(user));
            }

            return(dtos);
        }
Ejemplo n.º 8
0
        public IEnumerable <UserDTO> GetMentorsNotInGroup(int[] usedMentors)
        {
            var unUSedMentors = db.Users.GetMentorsNotInGroup(usedMentors);

            if (unUSedMentors == null)
            {
                return(null);
            }

            var mentorDtos = new List <UserDTO>();

            foreach (var item in unUSedMentors)
            {
                mentorDtos.Add(DtoFactory.UserModelToUserDTO(item));
            }

            return(mentorDtos);
        }
Ejemplo n.º 9
0
        public UserDTO GetUserByEmail(string email)
        {
            var user = db.Users.GetUserByEmail(email);

            return(user == null ? null : DtoFactory.UserModelToUserDTO(user));
        }
Ejemplo n.º 10
0
        public UserDTO GetUserByPhoneNumber(string phoneNumber)
        {
            var userModel = db.Users.GetUserByPhoneNumber(phoneNumber);

            return(userModel == null ? null : DtoFactory.UserModelToUserDTO(userModel));
        }
Ejemplo n.º 11
0
        public UserDTO GetUserById(int id)
        {
            var userModel = db.Users.GetUserById(id);

            return(userModel == null ? null : DtoFactory.UserModelToUserDTO(userModel));
        }