Beispiel #1
0
 private void LoginButtonClicked(object sender, RoutedEventArgs routedEventArgs)
 {
     UpdateActivities();
     try
     {
         ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
         UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
         if (!IsAccount(unitOfWork))
         {
             if (IsValidAccountPassword())
             {
                 if (IsActiveUser(unitOfWork))
                 {
                     OpenWindowUser();
                 }
                 else
                 {
                     MessageBox.Show("La cuenta no esta activa", "Cuenta inactiva", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                 }
             }
             else
             {
                 MessageBox.Show("Contraseña incorrecta", "Login Fallido", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         else
         {
             MessageBox.Show("Usuario incorrecto", "Login Fallido", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (EntityException)
     {
         MessageBox.Show("No se pudo Iniciar sesión. Intente más tarde", "Inicio de sesión Fallido", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #2
0
        private void LoadActiveCoordinator()
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                Coordinator retrievedCoordinator = unitOfWork.Coordinators.GetActiveCoordinator();
                if (retrievedCoordinator != null)
                {
                    Coordinator = retrievedCoordinator;
                    PrintUserGender();
                }
                else
                {
                    MessageBox.Show("Error. No existe ningún coordinador activo en la base de datos.");
                    GoBackToCoordinatorConsultation();
                }
            }
            catch (SqlException)
            {
                MessageBox.Show("No hay conexión a la base de datos. Intente más tarde");
                GoBackToCoordinatorConsultation();
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
Beispiel #3
0
        private void TryRegisterNewCoordinator()
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                if (!CoordinatorIsAlreadyRegistered(unitOfWork))
                {
                    if (!ThereIsAnActiveCoordinator(unitOfWork))
                    {
                        HashAccountPassword();
                        RegisterNewCoordinator(unitOfWork);
                        MessageBox.Show("Coordinador registrado exitosamente");
                        GoBackToManagerMenu();
                    }
                    else
                    {
                        MessageBox.Show("Ya existe un coordinador activo en el sistema.");
                    }
                }
                else
                {
                    MessageBox.Show("Este coordinador ya está registrado");
                }
            }catch (EntityException)
            {
                MessageBox.Show("Sin conexión a bd");
            }
            finally
            {
                unitOfWork.Complete();
                unitOfWork.Dispose();
            }
        }
Beispiel #4
0
        private void GeneratePartialReportButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                Assignment assignment = unitOfWork.Assignments.FindFirstOccurence(Assignment => Assignment.Enrollment == _practicionerEnrollment);
                if (assignment != null)
                {
                    Practicioner practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.Enrollment.Equals(_practicionerEnrollment));
                    if (practicioner.Group != null)
                    {
                        IEnumerable <ActivityPracticioner> activities = unitOfWork.ActivityPracticioners.Find(ActivityPracticioner => ActivityPracticioner.Enrollment.Equals(_practicionerEnrollment) &&
                                                                                                              ActivityPracticioner.Activity.ActivityType == ActivityType.PartialReport && ActivityPracticioner.Activity.ActivityStatus == ActivityStatus.ACTIVE);
                        if (IENumerableHasActivityPracticioners(activities))
                        {
                            IEnumerable <PartialReport> partialReports = unitOfWork.PartialReports.Find(PartialReport => PartialReport.Enrollment.Equals(practicioner.Enrollment));
                            if (IENumberPartialRepot(partialReports) < 2)
                            {
                                PartialReportGeneration partialReportGeneration = new PartialReportGeneration();
                                if (partialReportGeneration.InitializePartialReportGeneration(_practicionerEnrollment))
                                {
                                    partialReportGeneration.Show();
                                    Close();
                                }
                                else
                                {
                                    MessageBox.Show("No hay conexión a la base de datos. Intente más tarde", "Generación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("No puede generar más de dos reportes parciales", "No se puede acceder", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("No tiene activas actividades de reporte parcial. Contacte a su profesor", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("No esta asignado a un grupo Contacte a su coordinador", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("No tiene un proyecto asignado. Contacte a su coordinador", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (EntityException)
            {
                MessageBox.Show("No hay conexión a la base de datos. Intente más tarde", "Generación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
Beispiel #5
0
        private void RequestProject(object sender, RoutedEventArgs routedEventArgs)
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                bool            practicionerHaveAProject            = unitOfWork.Practicioners.PracticionerHasActiveProject(_practicionerEnrollment);
                IList <Project> projecsAvailableForThosPracticioner = unitOfWork.Projects.GetProjectsAvailableToRequest(_practicionerEnrollment);
                int             requestMade = unitOfWork.RequestProjects.GetPracticionerRequest(_practicionerEnrollment);
                if (practicionerHaveAProject || projecsAvailableForThosPracticioner.Count == 0 || requestMade == 3)
                {
                    MessageBox.Show("Ya has solocitado un proyecto o no hay proyectos disponibles", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    RequestProjects requestProject = new RequestProjects(_practicionerEnrollment);
                    requestProject.Show();
                    Close();
                }
            }
            catch (EntityException)
            {
                MessageBox.Show("No hay conexión a la base de datos. Intente más tarde", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
Beispiel #6
0
        private void AddActivityToPracticioners()
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                IList <Practicioner> practicioners = unitOfWork.Activities.GetPracticionersToActivity(_group);
                int idActivity = unitOfWork.Activities.GetId();
                ActivityPracticioner activity = new ActivityPracticioner
                {
                    Qualification = 0,
                    IdActivity    = idActivity,
                    ActivityPracticionerStatus = ActivityPracticionerStatus.NOTQUALIFIED
                };
                foreach (Practicioner practicioner in practicioners)
                {
                    activity.Enrollment = practicioner.Enrollment;
                    unitOfWork.ActivityPracticioners.Add(activity);
                    unitOfWork.Complete();
                }

                unitOfWork.Dispose();
            }
            catch (EntityException)
            {
                CatchDBException();
            }
        }
Beispiel #7
0
 public UnitOfWork(ProfessionalPracticesContext context)
 {
     _context            = context;
     Accounts            = new Repository <Account>(_context);
     Assignments         = new Repository <Assignment>(_context);
     Coordinators        = new CoordinatorRepository(_context);
     LinkedOrganizations = new LinkedOrganizationRepository(_context);
     Practicioners       = new PracticionerRepository(_context);
     Projects            = new ProjectRepository(_context);
     PartialReports      = new Repository <PartialReport>(_context);
     MonthlyReports      = new MonthlyReportRepository(_context);
     RequestProjects     = new RequestProjectRepository(_context);
     ResponsibleProjects = new ResponsibleProjectRepository(_context);
     Teachers            = new TeacherRepository(_context);
     Users   = new UserRepository(_context);
     States  = new StateRepository(_context);
     Sectors = new Repository <Sector>(_context);
     Phones  = new PhoneRepository(_context);
     SchedulingActivities = new Repository <SchedulingActivity>(_context);
     Groups                = new GroupRepository(_context);
     Activities            = new ActivityRepository(_context);
     ActivityPracticioners = new Repository <ActivityPracticioner>(_context);
     Documents             = new Repository <Document>(_context);
     ActivityMades         = new Repository <ActivityMade>(_context);
     AdvanceQuestions      = new Repository <AdvanceQuestion>(_context);
 }
Beispiel #8
0
        public void TestInitialize()
        {
            string          dateConvert = "2021-04-04 12:14:11";
            IFormatProvider format      = new System.Globalization.CultureInfo("es-ES", false);
            DateTime        date        = new DateTime();

            date = DateTime.ParseExact(dateConvert, "yyyy-MM-dd HH:mm:ss", format);

            _data = new List <ActivityPracticioner>
            {
                new ActivityPracticioner
                {
                    IdActivityPracticioner     = 9,
                    Qualification              = 0,
                    ActivityPracticionerStatus = ActivityPracticionerStatus.NOTQUALIFIED,
                    Enrollment = "zS18012149",
                    Activity   = new Activity
                    {
                        IdActivity         = 1,
                        Name               = "Primer reporte parcial",
                        ActivityType       = ActivityType.PartialReport,
                        ActivityStatus     = ActivityStatus.ACTIVE,
                        Description        = "Entregar el primer reporte parcial corresponsdiente a 200 horas.",
                        ValueActivity      = 10,
                        StartDate          = new DateTime(),
                        FinishDate         = date,
                        StaffNumberTeacher = "5678"
                    }
                }
            };
            DbSet <ActivityPracticioner> _mockSet     = DbContextMock.GetQueryableMockDbSet(_data, x => x.IdActivityPracticioner);
            ProfessionalPracticesContext _mockContext = DbContextMock.GetContext(_mockSet);

            _unitOfWork = new UnitOfWork(_mockContext);
        }
Beispiel #9
0
        public void AddReport()
        {
            List <Document> data = new List <Document>
            {
                new Document
                {
                    IdDocument = 9,
                    Name       = "DoctoProyecto.docx"
                }
            };
            DbSet <Document>             _mockSet     = DbContextMock.GetQueryableMockDbSet(data, x => x.IdDocument);
            ProfessionalPracticesContext _mockContext = DbContextMock.GetContext(_mockSet);
            UnitOfWork unitOfWork     = new UnitOfWork(_mockContext);
            Document   documentUpdate = unitOfWork.Documents.Get(9);

            documentUpdate.Name         = "DoctoProyecto.docx";
            documentUpdate.RouteSave    = "C:/Users/MARTHA/Documents/Activity/1";
            documentUpdate.TypeDocument = "Reporte Mensual";
            documentUpdate.TypeDocument = "Reporte Parcial";
            DateTime deliveryDate = DateTime.Now;

            documentUpdate.DeliveryDate = deliveryDate;

            ActivityPracticioner activityPracticionerUpdate = _unitOfWork.ActivityPracticioners.Get(9);

            activityPracticionerUpdate.Activity.ActivityStatus = ActivityStatus.ACTIVE;
            activityPracticionerUpdate.Answer = "Entrega";
            int expected = 1;
            int actual   = _data.Count;

            Assert.AreEqual(expected, actual);
        }
Beispiel #10
0
        public void AddActivityCorrect()
        {
            List <Activity>              actvities   = new List <Activity>();
            DbSet <Activity>             mockSet     = DbContextMock.GetQueryableMockDbSet(actvities, a => a.IdActivity);
            ProfessionalPracticesContext mockContext = DbContextMock.GetContext(mockSet);
            UnitOfWork unitOfWork  = DbContextMock.GetUnitOfWork(mockContext);
            string     date        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Activity   newActivity = new Activity
            {
                IdGroup        = 1,
                Name           = "Actividad  2 reporte mensual",
                ActivityType   = ActivityType.MonthlyReport,
                ActivityStatus = ActivityStatus.ACTIVE,
                IdActivity     = 2,
                Description    = " Deberan de subir su primer reporte mensual",
                ValueActivity  = 100,
                StartDate      = Convert.ToDateTime(date),
                FinishDate     = Convert.ToDateTime(date),
                teacher        = new Teacher
                {
                    StaffNumber = "12345"
                }
            };

            unitOfWork.Activities.Add(newActivity);

            int expected = 1;
            int actual   = actvities.Count;

            Assert.AreEqual(expected, actual);
        }
        private void DeleteButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            ResponsibleProject responsibleProject = ((ResponsibleProject)ListViewResponsibleProject.SelectedItem);

            try
            {
                ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
                bool       responsibleProjectIsAssigned = unitOfWork.ResponsibleProjects.ResponsibleProjectIsAssigned(responsibleProject.IdResponsibleProject);
                if (responsibleProjectIsAssigned)
                {
                    MessageBox.Show("El responsable del proyecto está asignado, no se puede eliminar", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    ResponsibleProjectDeletion deleteResponsibleProject = new ResponsibleProjectDeletion();
                    deleteResponsibleProject.InitializeDataResponsibleProject(responsibleProject);
                    deleteResponsibleProject.Show();
                    Close();
                }
            }
            catch (EntityException)
            {
                MessageBox.Show("No se pudo obtener información de la base de datos. Intente más tarde", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void RegisterActivitiesMade_Exists()
        {
            DateTime                     localDate       = DateTime.Now;
            List <ActivityMade>          activitiesMades = new List <ActivityMade>();
            DbSet <ActivityMade>         mockSet         = DbContextMock.GetQueryableMockDbSet(activitiesMades, p => p.IdActivity);
            ProfessionalPracticesContext mockContext     = DbContextMock.GetContext(mockSet);
            UnitOfWork                   unitOfWork      = DbContextMock.GetUnitOfWork(mockContext);
            List <ActivityMade>          newActivities   = new List <ActivityMade>
            {
                new ActivityMade
                {
                    Name            = "Pruebas",
                    IdPartialReport = 1,
                    PlannedWeek     = "S1 S2 S3",
                    RealWeek        = "S1 S2 S3"
                },
                new ActivityMade
                {
                    Name            = "Modelo de dominio",
                    IdPartialReport = 1,
                    PlannedWeek     = "S1 S2 S3",
                    RealWeek        = "S1 S2 S3"
                }
            };

            unitOfWork.ActivityMades.AddRange(newActivities);
            int expected = 2;
            int actual   = newActivities.Count;

            Assert.AreEqual(expected, actual);
        }
Beispiel #13
0
        private void DeleteButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("¿Seguro desea eliminar el profesor?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                try
                {
                    ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                    UnitOfWork unitOfWork    = new UnitOfWork(professionalPracticesContext);
                    Teacher    deleteTeacher = unitOfWork.Teachers.Get(teacher.StaffNumber);
                    deleteTeacher.User.UserStatus = UserStatus.INACTIVE;
                    int rowsAffected = unitOfWork.Complete();
                    unitOfWork.Dispose();
                    if (rowsAffected == 1)
                    {
                        MessageBox.Show("El Profesor se eliminó exitosamente", "Elimiación Exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("El Profesor no pudo eliminarse", "Eliminación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (EntityException)
                {
                    MessageBox.Show("El Profesor no pudo eliminarse", "Eliminación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                TeacherConsultation teacherConsultation = new TeacherConsultation();
                teacherConsultation.Show();
                Close();
            }
        }
Beispiel #14
0
        private void LoadReportsInformation()
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                IList <ActivityPracticioner> partialReport = unitOfWork.Practicioners.GetPracticionerPartialReports(_enrollment);
                foreach (ActivityPracticioner partial in partialReport)
                {
                    ListViewPartialReport.Items.Add(partial);
                }

                IList <ActivityPracticioner> monthlyReport = unitOfWork.Practicioners.GetPracticionerMonthlyReports(_enrollment);
                foreach (ActivityPracticioner monthly in monthlyReport)
                {
                    ListViewMonthlyReport.Items.Add(monthly);
                }
                _hourCovered = unitOfWork.Practicioners.GetAccumulatedHours(_enrollment);
            }
            catch (EntityException)
            {
                ShowException();
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
        private void DeleteButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            Practicioner practicioner = ((Practicioner)ListViewPracticioners.SelectedItem);

            try
            {
                ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
                bool       practicionerCantBeDeleted = unitOfWork.Practicioners.PracticionerHasActiveProject(practicioner.Enrollment);
                unitOfWork.Practicioners.PracticionerHasActiveProject(practicioner.Enrollment);
                if (practicionerCantBeDeleted)
                {
                    MessageBox.Show("El practicante tiene asignado un proyecto activo, no se puede eliminar", "No se puede eliminar", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    PracticionerDeletion practicionerDeletion = new PracticionerDeletion();
                    practicionerDeletion.InitializeDataPracticioner(practicioner);
                    practicionerDeletion.Show();
                    Close();
                }
            }
            catch (EntityException)
            {
                MessageBox.Show("No hay conexión con la base de datos. Por favor intente más tarde", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                CoordinatorMenu coordinatorMenu = new CoordinatorMenu();
                coordinatorMenu.Show();
                this.Close();
            }
        }
Beispiel #16
0
        public void TestInitialize()
        {
            _practicioners = new List <Practicioner> {
                new Practicioner
                {
                    Enrollment = "zS18012124",
                }
            };

            _request = new List <RequestProject>
            {
                new RequestProject
                {
                    IdRequestProject = 1,
                    RequestDate      = DateTime.Now,
                    IdProject        = 1,
                    Enrollment       = "zS18012124",
                    RequestStatus    = RequestStatus.REQUESTED
                }
            };

            _mockSetPracticioners = DbContextMock.GetQueryableMockDbSet(_practicioners, p => p.Enrollment);
            _mockContext          = DbContextMock.GetContext(_mockSetPracticioners);
            _mockSetRequest       = DbContextMock.GetQueryableMockDbSet(_request, r => r.IdRequestProject);
            _mockContext          = DbContextMock.GetContext(_mockSetRequest);
            _unitOfWork           = new UnitOfWork(_mockContext);
        }
Beispiel #17
0
 private void AddButtonClicked(object sender, RoutedEventArgs routedEventArgs)
 {
     CreateActivity();
     if (ValidateData())
     {
         ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
         UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
         try
         {
             unitOfWork.Activities.Add(Activity);
             unitOfWork.Complete();
             AddActivityToPracticioners();
             MessageBox.Show("Actividad agregada exitosamente.");
             this.Close();
         }
         catch (SqlException)
         {
             CatchDBException();
         }
         finally
         {
             unitOfWork.Dispose();
         }
     }
     else
     {
         MessageBox.Show("Ingrese datos válidos");
     }
 }
Beispiel #18
0
        public void RegisterSchedulingActivities_Exists()
        {
            List <SchedulingActivity> schedulingActivities = new List <SchedulingActivity>()
            {
                new SchedulingActivity
                {
                    Month     = "Febrero",
                    Activity  = "Análisis de requerimientos, recopilación de información, documentación y revisión de procedimientos.Capacitación en el IDE de desarrollo y metodología.",
                    IdProject = 3
                },
                new SchedulingActivity
                {
                    Month     = "Mayo",
                    Activity  = "Pruebas y ajustes",
                    IdProject = 3
                }
            };
            DbSet <SchedulingActivity>   mockSet     = DbContextMock.GetQueryableMockDbSet(schedulingActivities, s => s.IdSchedulingActivity);
            ProfessionalPracticesContext mockContext = DbContextMock.GetContext(mockSet);
            UnitOfWork unitOfWork = DbContextMock.GetUnitOfWork(mockContext);

            unitOfWork.SchedulingActivities.AddRange(schedulingActivities);
            int expected = 4;
            int actual   = schedulingActivities.Count;

            Assert.AreEqual(expected, actual);
        }
Beispiel #19
0
 private void ConsultTeacherButtonClicked(object sender, RoutedEventArgs routedEventArgs)
 {
     ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
     UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
     try
     {
         IEnumerable<Teacher> thereAreTeachers = unitOfWork.Teachers.GetAll();
         if (IENumerableHasTeachers(thereAreTeachers))
         {
             TeacherConsultation teacherConsultation = new TeacherConsultation();
             teacherConsultation.Show();
             Close();
         }
         else
         {
             MessageBox.Show("No hay profesores registrados. Por favor registre uno");
         }
     }
     catch (SqlException)
     {
         MessageBox.Show("No hay conexión a la base de datos. Intente más tarde");
     }
     catch (EntityException)
     {
         MessageBox.Show("No hay conexión a la base de datos. Intente más tarde");
     }
     finally
     {
         unitOfWork.Dispose();
     }
     
 }
Beispiel #20
0
        public void SoftDeleteResponsibleProject_Exists()
        {
            List <ResponsibleProject>    responsiblesProject = new List <ResponsibleProject>();
            DbSet <ResponsibleProject>   mockSet             = DbContextMock.GetQueryableMockDbSet(responsiblesProject, r => r.EmailAddress);
            ProfessionalPracticesContext mockContext         = DbContextMock.GetContext(mockSet);
            UnitOfWork         unitOfWork         = DbContextMock.GetUnitOfWork(mockContext);
            ResponsibleProject responsibleProject = new ResponsibleProject
            {
                IdResponsibleProject = 1,
                Name         = "Gustavo Antonio",
                LastName     = "Ruiz Zapata",
                EmailAddress = "*****@*****.**",
                Charge       = "Jefe de departamento de Tecnología Educativa"
            };

            responsiblesProject.Add(responsibleProject);
            ResponsibleProject responsobleProjectCurrent = unitOfWork.ResponsibleProjects.Get(responsibleProject.IdResponsibleProject);

            if (responsobleProjectCurrent != null)
            {
                responsobleProjectCurrent.ResponsibleProjectStatus = ResponsibleProjectStatus.INACTIVE;
            }
            responsiblesProject.Remove(responsibleProject);
            int expected = 0;
            int actual   = responsiblesProject.Count;

            Assert.AreEqual(expected, actual);
        }
Beispiel #21
0
        public void TestInitialize()
        {
            _teacherValidator = new TeacherValidator(true);
            _teachers         = new List <Teacher> {
                new Teacher
                {
                    StaffNumber      = "54321",
                    RegistrationDate = DateTime.Now,
                    User             = new User
                    {
                        IdUser         = 1,
                        Name           = "Alejandra",
                        LastName       = "Luna Ceballos",
                        Gender         = Gender.FEMALE,
                        UserStatus     = UserStatus.ACTIVE,
                        Email          = "*****@*****.**",
                        AlternateEmail = "*****@*****.**",
                        PhoneNumber    = "2281213456"
                    }
                }
            };

            _mockSet     = DbContextMock.GetQueryableMockDbSet(_teachers, t => t.StaffNumber);
            _mockContext = DbContextMock.GetContext(_mockSet);
            _unitOfWork  = DbContextMock.GetUnitOfWork(_mockContext);
        }
Beispiel #22
0
        public void TestInitialize()
        {
            _data = new List <Teacher>
            {
                new Teacher
                {
                    StaffNumber = "124987",
                    User        = new User
                    {
                        Name           = "Jorge Octavio",
                        LastName       = "Ocharan Hernandez",
                        Gender         = Gender.MALE,
                        UserStatus     = UserStatus.ACTIVE,
                        PhoneNumber    = "2284564791",
                        UserType       = UserType.Teacher,
                        Email          = "*****@*****.**",
                        AlternateEmail = "*****@*****.**",
                        Account        = new Account
                        {
                            Username   = "******",
                            Password   = "******",
                            FirstLogin = true
                        }
                    }
                }
            };
            DbSet <Teacher> _mockSet = DbContextMock.GetQueryableMockDbSet(_data, x => x.StaffNumber);
            ProfessionalPracticesContext _mockContext = DbContextMock.GetContext(_mockSet);

            _unitOfWork = new UnitOfWork(_mockContext);
        }
Beispiel #23
0
        private void ConsultProgressButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                bool practicionerHaveAProject = unitOfWork.Practicioners.PracticionerHasActiveProject(_practicionerEnrollment);
                if (practicionerHaveAProject)
                {
                    ConsultProgress consultProgress = new ConsultProgress(_practicionerEnrollment);
                    consultProgress.Show();
                    Close();
                }
                else
                {
                    MessageBox.Show("No tiene un proyecto asignado. Contacte a su coordinador", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (EntityException)
            {
                MessageBox.Show("No hay conexión a la base de datos. Intente más tarde", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
 private async void GenerateReportButtonClickedAsync(object sender, RoutedEventArgs e)
 {
     if (TextBoxSavingPath.Text == "")
     {
         MessageBox.Show("Por favor ingrese una ruta de guardado válida");
     }
     else
     {
         ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
         UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
         try
         {
             LoadDataFromDatabase(unitOfWork);
             GenerateReportAsync();
             MessageBox.Show("El reporte fue generado con éxito");
         }
         catch (SqlException)
         {
             MessageBox.Show("Error en la conexión con la base de datos. Por favor, intente más tarde");
         }
         catch (EntityException)
         {
             MessageBox.Show("Error en la conexión con la base de datos. Por favor, intente más tarde");
         }
         catch (NullReferenceException)
         {
             MessageBox.Show("No se pudo generar el reporte");
         }
         finally
         {
             unitOfWork.Dispose();
             GoBackToCoordinatorMenu();
         }
     }
 }
Beispiel #25
0
        private void LoadInformation()
        {
            ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
            UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);

            try
            {
                IEnumerable <Group> groups = unitOfWork.Groups.GetAll();
                foreach (Group group in groups)
                {
                    ListViewGroups.Items.Add(group);
                }
            }
            catch (EntityException)
            {
                MessageBox.Show("No hay conexión con la base de datos. Intente más tarde");
                CoordinatorMenu coordinatorMenu = new CoordinatorMenu();
                coordinatorMenu.Show();
                this.Close();
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
Beispiel #26
0
 public void TestInitialize()
 {
     _data = new List <User>
     {
         new User
         {
             IdUser         = 1,
             Name           = "Martha Miroslava",
             LastName       = "Ortiz",
             Gender         = Gender.FEMALE,
             UserStatus     = UserStatus.ACTIVE,
             Email          = "*****@*****.**",
             AlternateEmail = "*****@*****.**",
             PhoneNumber    = "9711609017",
             UserType       = UserType.Coordinator,
             Account        = new Account
             {
                 IdAccount = 1,
                 Username  = "******",
                 Password  = "******"
             }
         }
     };
     _mockSet     = DbContextMock.GetQueryableMockDbSet(_data, x => x.IdUser);
     _mockContext = DbContextMock.GetContext(_mockSet);
     _repository  = new Repository <User>(_mockContext);
     _unitOfWork  = new UnitOfWork(_mockContext);
 }
Beispiel #27
0
        private void DeleteButtonClicked(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("¿Seguro que desea eliminar al coordinador?",
                                                                "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
                try
                {
                    unitOfWork.Coordinators.SetCoordinatorStatusAsInactive(Coordinator.StaffNumber);
                    unitOfWork.Complete();
                    MessageBox.Show("Coordinador eliminado exitosamente");
                }
                catch (SqlException)
                {
                    MessageBox.Show("No hay conexión a la base de datos. Intente más tarde");
                }
                finally
                {
                    unitOfWork.Dispose();
                    GoBackToCoordinatorConsultation();
                }
            }
        }
        private void DeleteActivityButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            SchedulingActivity schedulingActivity = ((SchedulingActivity)ListViewSchedulingActivities.SelectedItem);
            MessageBoxResult   messageBoxResult   = MessageBox.Show("¿Seguro desea eliminar la actividad?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes && !object.ReferenceEquals(null, schedulingActivity))
            {
                try
                {
                    ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                    UnitOfWork         unitOfWork = new UnitOfWork(professionalPracticesContext);
                    SchedulingActivity schedulingActivityDelete = unitOfWork.SchedulingActivities.Get(schedulingActivity.IdSchedulingActivity);
                    unitOfWork.SchedulingActivities.Remove(schedulingActivityDelete);
                    int rowsAffected = unitOfWork.Complete();
                    unitOfWork.Dispose();
                    if (rowsAffected == 1)
                    {
                        MessageBox.Show("La actividad se eliminó exitosamente", "Eliminación exitosa", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("No se pudo eliminar la actividad. Intente más tarde.", "Eliminación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (EntityException)
                {
                    MessageBox.Show("No se pudo eliminar la actividad. Intente más tarde.", "Eliminación Fallida", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                UpdateListViewSchedulingActivities();
            }
        }
Beispiel #29
0
        public void TestInitialize()
        {
            _data = new List <Coordinator>
            {
                new Coordinator
                {
                    StaffNumber      = "XGC16215",
                    RegistrationDate = DateTime.Now,
                    DischargeDate    = null,
                    User             = new User
                    {
                        IdUser         = 1,
                        Name           = "Eduardo Aldair",
                        LastName       = "Hernández Solís",
                        Gender         = Gender.MALE,
                        UserStatus     = UserStatus.ACTIVE,
                        Email          = "*****@*****.**",
                        AlternateEmail = "*****@*****.**",
                        PhoneNumber    = "2298046218",
                        Account        = new Account
                        {
                            Username   = "******",
                            Password   = "******",
                            FirstLogin = true
                        }
                    }
                }
            };

            _mockSet     = DbContextMock.GetQueryableMockDbSet(_data, x => x.StaffNumber);
            _mockContext = DbContextMock.GetContext(_mockSet);
            _repository  = new CoordinatorRepository(_mockContext);
            _unitOfWork  = new UnitOfWork(_mockContext);
        }
Beispiel #30
0
        private void DeleteButtonClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("¿Seguro desea eliminar el practicante?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext();
                UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext);
                try
                {
                    unitOfWork.Practicioners.SetPracticionerStatusAsInactive(practicioner.Enrollment);
                    unitOfWork.Complete();
                    MessageBox.Show("Practicante eliminado exitosamente");
                }
                catch (EntityException)
                {
                    MessageBox.Show("No hay conexión a la base de datos. Por favor intente más tarde");
                }
                finally
                {
                    unitOfWork.Dispose();
                    PracticionerConsult practicionerConsult = new PracticionerConsult();
                    practicionerConsult.Show();
                    this.Close();
                }
            }
        }