Exemplo n.º 1
0
        public async Task AddStudentTutor(string tutorId, int moduleId)
        {
            var currentUserId = _currentUserService.GetUserId();

            if (currentUserId == tutorId)
            {
                throw new InvalidOperationException($"Could not add tutor (id='{tutorId}'): you can't add yourself.");
            }

            var tutorExists = await _moduleTutorsRepository.Exists(moduleId, tutorId);

            if (!tutorExists)
            {
                throw new InvalidOperationException($"Could not add tutor (id='{tutorId}'): not found.");
            }

            var tutorIgnoresStudent = await _studentTutorIgnoresRepository.Exists(sti => sti.TutorId == tutorId && sti.StudentId == currentUserId);

            if (tutorIgnoresStudent)
            {
                throw new InvalidOperationException($"Could not add tutor (id='{tutorId}'): he has ignored you.");
            }

            var studentTutor = new StudentTutor
            {
                StudentId = currentUserId,
                TutorId   = tutorId,
                ModuleId  = moduleId
            };

            await _studentTutorsRepository.Create(studentTutor);
        }
Exemplo n.º 2
0
        public void Informations()
        {
            ConsoleKeyInfo cki;
            Console.WriteLine("Your informations >");
            Console.WriteLine(ToString());
            Console.WriteLine($"Sexe : {Sexe}  Phone Number : {PhoneNumber}    Personal Email : {EmailPerso}\n " +
                $"Adress : {Adress}   Place of birth : {PlaceBirth} ");
            do
            {
                Console.WriteLine("Enter the number of the information you want to change");
                Console.WriteLine("0 : nothing\n" +
                    "1 : adress\n" +
                    "2 : personnal email\n" +
                    "3 : phone number\n" +
                    "4 : tutors");
                int nb = Convert.ToInt16(Console.ReadLine());

                switch (nb)
                {
                    case 0:
                        break;

                    case 1:
                        Console.WriteLine("Enter your new address");
                        Adress = Console.ReadLine();
                        break;

                    case 2:
                        Console.WriteLine("Enter your new email adress");
                        EmailPerso = Console.ReadLine();
                        break;

                    case 3:
                        Console.WriteLine("Enter your new phone number");
                        PhoneNumber = Console.ReadLine();
                        break;

                    case 4:
                        StudentTutor.Modification();
                        break;
                }
                cki = Console.ReadKey();
            }
            while (cki.Key != ConsoleKey.Escape);
        }