public async Task <bool> CreateDiscipline(Discipline dis)
        {
            try
            {
                _disciplineRepository.Create(dis);
                await _disciplineRepository.SaveAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Exemplo n.º 2
0
        public ICommandResult Handle(DisciplineInputRegister command)
        {
            int professorWorkload = _PREP.GetWorkload(command.ProfessorId);
            var discipline        = new Discipline(command.Name, new Course(command.CourseId), new Professor(command.ProfessorId), command.WeeklyWorkload, command.Period, professorWorkload);
            var result            = new StandardResult();

            result.AddRange(discipline.Notifications);
            if (result.Notifications.Count == 0)
            {
                _DREP.Create(discipline);
                result.Notifications.Add("Success", "O Acadêmico foi salvo");
            }
            return(result);
        }
Exemplo n.º 3
0
        public void Init()
        {
            _AREPEC = new Infra.EvaluationContext.ActivityRepository(new MSSQLDB(new DBConfiguration()));
            _AREPAC = new Infra.ActivityContext.ActivityRepository(new MSSQLDB(new DBConfiguration()));
            _DREP   = new DisciplineRepository(new MSSQLDB(new DBConfiguration()));
            _PREP   = new Infra.ProfessorContext.ProfessorRepository(new MSSQLDB(new DBConfiguration()));
            _SREP   = new StudentRepository(new MSSQLDB(new DBConfiguration()));
            var db = new SqlConnection(new DBConfiguration().StringConnection);

            // Create Course
            course = new Entities.StudentContext.Entities.Course(Guid.NewGuid());
            sql    = "INSERT INTO [Course] ([Id], [Name]) VALUES (@Id, 'LTP')";
            db.Execute(sql, param: new { Id = course.CourseId });

            // Create Professor
            professor = new Entities.ProfessorContext.Entities.Professor("Thelmaryo", "Vieira Lima", "034.034.034-00", "*****@*****.**", "123", EDegree.Master, "123", "123");
            _PREP.Create(professor);

            // Create Discipline
            disciplineCC = new Entities.CourseContext.Entities.Discipline("Psicologia", new Entities.CourseContext.Entities.Course(course.CourseId), new Entities.CourseContext.Entities.Professor(professor.Id), 20, 1, 0);
            _DREP.Create(disciplineCC);

            disciplineAC = new Entities.ActivityContext.Entities.Discipline(disciplineCC.Id, "Psicologia");

            // Create Student
            string CPF      = "117.400.002-34";
            string password = new Encryptor().Encrypt(CPF.Replace("-", "").Replace(".", ""), out string salt);

            student = new Entities.StudentContext.Entities.Student(course, DateTime.Now, "Abmael", "Araujo", CPF, "*****@*****.**", "1234-1234", "F", "França", "AraguainaSul", "Norte", password, salt);
            _SREP.Create(student);

            // Create Student
            string CPFEdit      = "344.245.132-97";
            string passwordEdit = new Encryptor().Encrypt(CPF.Replace("-", "").Replace(".", ""), out string saltEdit);

            studentEdit = new Entities.StudentContext.Entities.Student(course, DateTime.Now, "Abmael", "Araujo", CPFEdit, "*****@*****.**", "1234-1234", "F", "França", "AraguainaSul", "Norte", passwordEdit, saltEdit);
            _SREP.Create(studentEdit);

            // Create Activity
            activityAC = new Entities.ActivityContext.Entities.Activity(disciplineAC, "AtividadeTest", DateTime.Now, 10, 10, 15, Guid.NewGuid());
            _AREPAC.Create(activityAC);

            // Create Activity
            _student   = new Student(student.Id);
            activityEC = new Activity(activityAC.Id, _student, "AtividadeTest", DateTime.Now, 8, 10);
            _AREPEC.Create(activityEC);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Создает дисциплину.
        /// </summary>
        /// <param name="discipline">Дисциплина.</param>
        /// <returns>Идентификатор созданной дисциплины.</returns>
        public int Create(DisciplineItem discipline)
        {
            if (string.IsNullOrEmpty(discipline.FullName))
            {
                throw new Exception("Поле 'FullName' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(discipline.ShortName))
            {
                throw new Exception("Поле 'ShortName' не должно быть пустым.");
            }

            if (string.IsNullOrEmpty(discipline.Mem))
            {
                throw new Exception("Поле 'Mem' не должно быть пустым.");
            }

            return(_disciplineRepository.Create(discipline));
        }
Exemplo n.º 5
0
        public void Init()
        {
            _PREP = new Infra.ProfessorContext.ProfessorRepository(new MSSQLDB(new DBConfiguration()));
            _DREP = new DisciplineRepository(new MSSQLDB(new DBConfiguration()));
            var db = new SqlConnection(new DBConfiguration().StringConnection);


            string CPF      = "034.034.034-00";
            string password = new Encryptor().Encrypt(CPF.Replace("-", "").Replace(".", ""), out string salt);

            professor = new Entities.ProfessorContext.Entities.Professor("Thelmaryo", "Vieira Lima", CPF, "*****@*****.**", "123", EDegree.Master, password, salt);
            _PREP.Create(professor);

            course = new Course("Psicologia");
            sql    = "INSERT INTO [Course] ([Id], [Name]) VALUES (@Id, @Name)";
            db.Execute(sql, param: new { course.Id, course.Name });

            discipline = new Discipline("Psicologia", new Course(course.Id), new Entities.CourseContext.Entities.Professor(professor.Id), 20, 1, 0);
            _DREP.Create(discipline);
        }
Exemplo n.º 6
0
        public void Init()
        {
            var db = new SqlConnection(new DBConfiguration().StringConnection);

            _AREP      = new ActivityRepository(new MSSQLDB(new DBConfiguration()));
            _DREP      = new DisciplineRepository(new MSSQLDB(new DBConfiguration()));
            Activities = new List <Guid>();
            var _PREP = new Infra.ProfessorContext.ProfessorRepository(new MSSQLDB(new DBConfiguration()));

            professor = new Professor("Thelmaryo", "Vieira Lima", "034.034.034-00", "*****@*****.**", "123", EDegree.Master, "123", "123");
            _PREP.Create(professor);

            var course = new Entities.CourseContext.Entities.Course("Sistemas de Informação");

            db.Execute("INSERT INTO Course(Id, Name) VALUES (@Id, @Name)", course);
            CourseId = course.Id;

            var discipline = new Entities.CourseContext.Entities.Discipline("Software Test", new Entities.CourseContext.Entities.Course(course.Id), new Entities.CourseContext.Entities.Professor(professor.Id), 10, 1, 0);

            _DREP.Create(discipline);
            Discipline = new Discipline(discipline.Id, discipline.Name);
        }
 public Discipline Create(Discipline discipline)
 {
     return(_disciplineRepository.Create(discipline));
 }