예제 #1
0
        public Enrollment CreateEnrollment(string userId, int instituteId)
        {
            ApplicationUser user      = repository.GetUser(userId).Result;
            Institute       institute = repository.GetInstitute(instituteId).Result;

            //inicializamos recursos
            Resource resource = repository.SaveResource(new Resource()).Result;

            //inicializamos software
            Software software = repository.SaveSoftware(new Software()).Result;

            //inicializamos talentos
            Talent talent = repository.SaveTalent(new Talent()).Result;

            //inicializamos scripts de ataque
            Script script = repository.SaveScript(new Script()).Result;

            //TODO: inicializamos profesores

            //creamos la matrícula
            Enrollment enrollment = repository.SaveEnrollment(new Enrollment(user, institute)).Result;

            //inicializamos el ordenador
            Computer computer = new Computer(
                string.Format("Ordenador de {0}", user.UserName),
                generatePosition(instituteId),
                true,
                resource,
                software,
                talent,
                script,
                enrollment);

            computer = repository.SaveComputer(computer).Result;

            CreateWelcomeMessage(institute, computer);

            return(enrollment);
        }