예제 #1
0
        public void Init()
        {
            conection             = new MSSQLDB(new DBConfiguration());
            _DREP                 = new DisciplineRepository(conection);
            _PREPProfessorContext = new Infra.ProfessorContext.ProfessorRepository(conection);
            _PREPCourseContext    = new Infra.CourseContext.ProfessorRepository(conection);
            _encryptor            = new Encryptor();
            handler               = new DisciplineCommandHandler(_DREP, _PREPCourseContext);

            var db = conection.GetCon();

            var    cpf      = "357.034.413-40";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            professor = new Entities.ProfessorContext.Entities.Professor("Lívia", "Emanuelly Elisa", cpf, "*****@*****.**", "(21) 2682-8370", EDegree.Master, password, salt);

            _PREPProfessorContext.Create(professor);

            // Create Course
            course = new Course(Guid.NewGuid());
            var sql = "INSERT INTO [Course] ([Id], [Name]) VALUES (@Id, 'LTP6')";

            db.Execute(sql, param: new { Id = course.Id });

            commandRegister = new DisciplineInputRegister()
            {
                Name           = "Filosofia",
                CourseId       = course.Id,
                ProfessorId    = professor.Id,
                WeeklyWorkload = 1,
                Period         = 1
            };
            discipline = new Discipline("Filosofia", course, new Professor(professor.Id), 1, 1, 0);

            _DREP.Create(discipline);

            commandUpdate = new DisciplineInputUpdate()
            {
                DisciplineId   = discipline.Id,
                Name           = "Matematica",
                CourseId       = course.Id,
                ProfessorId    = professor.Id,
                WeeklyWorkload = 2,
                Period         = 2
            };

            commandDelete = new DisciplineInputDelete()
            {
                DisciplineId = discipline.Id
            };
        }
예제 #2
0
        public ICommandResult Handle(DisciplineInputDelete command)
        {
            _DREP.Delete(command.DisciplineId);
            var result = new StandardResult();

            if (_DREP.Get(command.DisciplineId) != null)
            {
                result.Notifications.Add("Error", "Não foi possivel deletar Discente!");
            }
            else
            {
                result.Notifications.Add("Success", "Discente Deletado");
            }

            return(result);
        }