public void PracticionerDeletedTest() { _unitOfWork.Practicioners.SetPracticionerStatusAsInactive("zS18012124"); Practicioner retrievedPracticioner = _unitOfWork.Practicioners.Get("zS18012124"); Assert.AreEqual(UserStatus.INACTIVE, retrievedPracticioner.User.UserStatus); }
public void RepeatedInformationTest() { Practicioner repeatedInformationPracticioner = new Practicioner { Enrollment = "zS18012124", Term = "FEBRERO - JULIO 2021", Credits = 285, User = new User { IdUser = 1, Name = "Ana Maria", LastName = "Herrera Espinosa", Gender = Gender.FEMALE, UserStatus = UserStatus.ACTIVE, Email = "*****@*****.**", AlternateEmail = "*****@*****.**", PhoneNumber = "2281564676", Account = new Account { Username = "******", Password = "******", FirstLogin = true } } }; bool expected = true; bool actual = _unitOfWork.Practicioners.PracticionerIsAlreadyRegistered(repeatedInformationPracticioner); Assert.AreEqual(expected, actual); }
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(); } }
public void InvalidInformationTest() { Practicioner invalidInformationPracticioner = new Practicioner { Enrollment = "AnaMaria", Term = "", Credits = 6, User = new User { IdUser = 1, Name = "123", LastName = "@@@@@", Gender = Gender.FEMALE, UserStatus = UserStatus.ACTIVE, Email = "zs1801212estudiantes.uv.mx", AlternateEmail = "ale_200200hotmail.com", PhoneNumber = "666666", Account = new Account { Username = "******", Password = "******", FirstLogin = true } } }; var result = _practicionerValidator.TestValidate(invalidInformationPracticioner); result.ShouldHaveValidationErrorFor("User.Name"); }
public void ValidInformationTest() { Practicioner newPracticioner = new Practicioner { Enrollment = "zS18012124", Term = "FEBRERO - JULIO 2021", Credits = 285, User = new User { IdUser = 1, Name = "Yazmin Alejandra", LastName = "Luna Herrera", Gender = Gender.FEMALE, UserStatus = UserStatus.ACTIVE, Email = "*****@*****.**", AlternateEmail = "*****@*****.**", PhoneNumber = "2281564676", Account = new Account { Username = "******", Password = "******", FirstLogin = true } } }; _unitOfWork.Practicioners.Add(newPracticioner); int expected = 2; int actual = _practicioners.Count; Assert.AreEqual(expected, actual); }
public void RepeatedInformationTest() { Practicioner repeatedInformationPracticioner = new Practicioner { Enrollment = "zS19012344", Term = "FEBRERO - JULIO 2021", Credits = 285, User = new User { IdUser = 1, Name = "Yazmin", LastName = "Luna Ceballos", Gender = Gender.FEMALE, UserStatus = UserStatus.ACTIVE, Email = "*****@*****.**", AlternateEmail = "*****@*****.**", PhoneNumber = "2289123456", Account = new Account { Username = "******", Password = "******", FirstLogin = true } } }; bool expected = true; bool actual = _unitOfWork.Practicioners.PracticionerIsAlreadyRegistered(repeatedInformationPracticioner); Assert.AreEqual(expected, actual); }
public void ValidInformationTest() { Practicioner newPracticioner = new Practicioner { Enrollment = "zS18012344", Term = "FEBRERO - JULIO 2021", Credits = 285, User = new User { IdUser = 1, Name = "Yazmin", LastName = "Luna", Gender = Gender.FEMALE, UserStatus = UserStatus.ACTIVE, Email = "*****@*****.**", AlternateEmail = "*****@*****.**", PhoneNumber = "2281564600", Account = new Account { Username = "******", Password = "******", FirstLogin = true } } }; var result = _practicionerValidator.TestValidate(newPracticioner); result.ShouldNotHaveAnyValidationErrors(); }
private void PracticionerSelectionChanged(object sender, SelectionChangedEventArgs e) { _selectedPracticioner = GetSelectedPracticioner(); if (_selectedPracticioner != null) { ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); try { ListViewSelectedProjects.Items.Clear(); _selectedPracticioner = unitOfWork.Practicioners.Get(_selectedPracticioner.Enrollment); List <RequestProject> requestedProjects = _selectedPracticioner.Requests; foreach (RequestProject requestedProject in requestedProjects) { ListViewSelectedProjects.Items.Add(requestedProject.Project.NameProject); } } catch (SqlException) { MessageBox.Show("Ha ocurrido un error en la conexión con la base de datos", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error); GoBackToCoordinatorMenu(); } catch (EntityException) { MessageBox.Show("Ha ocurrido un error en la conexión con la base de datos", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error); GoBackToCoordinatorMenu(); } finally { unitOfWork.Dispose(); } } }
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(); } }
private void ModifyButtonClicked(object sender, RoutedEventArgs routedEventArgs) { Practicioner practicioner = (Practicioner)ListViewPracticioners.SelectedItem; PracticionerModification practicionerModification = new PracticionerModification(practicioner.Enrollment); practicionerModification.Show(); this.Close(); }
public int GetIdActivityMonthlyReportPracticioner(string enrollment) { Practicioner practicioner = _context.Set <Practicioner>().SingleOrDefault(Practicioner => Practicioner.Enrollment == enrollment); Activity activity = _context.Set <Activity>().SingleOrDefault(Activity => Activity.IdGroup == practicioner.IdGroup && Activity.ActivityType == ActivityType.MonthlyReport && Activity.ActivityStatus == ActivityStatus.ACTIVE); ActivityPracticioner activityPracticioner = _context.Set <ActivityPracticioner>().SingleOrDefault(ActivityPracticioner => ActivityPracticioner.Enrollment == enrollment && ActivityPracticioner.IdActivity == activity.IdActivity); return(activityPracticioner.IdActivityPracticioner); }
private void DiscardPracticioner(object sender, RoutedEventArgs routedEventArgs) { Practicioner practicioner = ((Practicioner)ListViewPracticionersSelected.SelectedItem); if (practicioner != null) { _practicionersAvailables.Add(practicioner); PracticionersSelected.Remove(practicioner); LoadPracticionerAvailableList(); LoadPracticionerSelectedList(); } }
private void SelectionPracticioner(object sender, RoutedEventArgs routedEventArgs) { Practicioner practicioner = ((Practicioner)ListViewPracticionersToAdd.SelectedItem); if (practicioner != null) { _practicionersInThisGroup.Add(practicioner); _practicionersSelectedToAdd.Remove(practicioner); LoadPracticionerInThisGroup(); LoadPracticionerSelectedList(); } }
private void AssignProjectButtonClicked(object sender, RoutedEventArgs e) { _selectedPracticioner = GetSelectedPracticioner(); _selectedProject = GetSelectedProject(); if (ProjectAndPracticionerHaveBeenSelected()) { SaveAssignmentOffice(); } else { MessageBox.Show("Por favor seleccione a un practicante y a un proyecto para poder realizar la asignación"); } }
public void InitializeDataPracticioner(Practicioner practicionerSent) { practicioner = practicionerSent; LabelEnrollment.Content = practicionerSent.Enrollment; LabelName.Content = practicionerSent.User.Name; LabelLastName.Content = practicionerSent.User.LastName; LabelEmail.Content = practicionerSent.User.Email; LabelAlternateEmail.Content = practicionerSent.User.AlternateEmail; LabelTerm.Content = practicionerSent.Term; LabelCredits.Content = practicionerSent.Credits; LabelPhone.Content = practicionerSent.User.PhoneNumber; PrintPracticionerGender(); }
public bool InitializePartialReportGeneration(string enrrollment) { try { ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); _practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.Enrollment == enrrollment); if (_practicioner != null) { _assignment = unitOfWork.Assignments.FindFirstOccurence(Assignment => Assignment.Practicioner.Enrollment == _practicioner.Enrollment); if (_assignment != null) { _teacher = unitOfWork.Teachers.FindFirstOccurence(Teacher => Teacher.StaffNumber == _practicioner.Group.StaffNumber); if (_teacher != null) { PartialReport partialReport = unitOfWork.PartialReports.FindFirstOccurence(PartialReport => PartialReport.Enrollment == _practicioner.Enrollment); if (partialReport != null) { _numberReport = "SEGUNDO"; CreateHours(false); } else { _numberReport = "PRIMERO"; CreateHours(true); } InitializeAssignment(); return(true); } else { return(false); } } else { return(false); } } else { return(false); } } catch (IOException) { return(false); } }
private void PracticionerListViewSelectionChanged(object sender, SelectionChangedEventArgs selectionChanged) { Practicioner practicioner = ((Practicioner)ListViewPracticioners.SelectedItem); if (practicioner != null) { ButtonModify.IsEnabled = true; if (practicioner.User.UserStatus == UserStatus.ACTIVE) { ButtonDelete.IsEnabled = true; } else { ButtonDelete.IsEnabled = false; } } }
public bool InitializeStackPanel(ActivityType activityType) { _activityTypeReport = "Añadir Reporte Mensual"; try { ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); Practicioner practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.IdUser == _User.IdUser); if (practicioner != null) { if (activityType.Equals(ActivityType.PartialReport)) { _activityTypeReport = "Añadir Reporte Parcial"; TextBlockNameActivity.Text = "Reportes Parcial"; _activityPracticioners = unitOfWork.ActivityPracticioners.Find(ActivityPracticioner => ActivityPracticioner.Enrollment.Equals(practicioner.Enrollment) && ActivityPracticioner.Activity.ActivityType.Equals(ActivityType.PartialReport)); } else { _activityPracticioners = unitOfWork.ActivityPracticioners.Find(ActivityPracticioner => ActivityPracticioner.Enrollment.Equals(practicioner.Enrollment) && ActivityPracticioner.Activity.ActivityType.Equals(ActivityType.MonthlyReport)); } if (IENumerableHasActivityPracticioners(_activityPracticioners)) { AddReportPartialInListView(); return(true); } else { return(false); } } else { return(false); } } catch (SqlException) { return(false); } catch (EntityException) { return(false); } }
private void DiscardPracticioner(object sender, RoutedEventArgs routedEventArgs) { Practicioner practicioner = ((Practicioner)ListViewPracticioners.SelectedItem); if (practicioner != null) { foreach (Practicioner practicionerAdd in PracticionersInThisGroupOriginal) { if (practicioner.Enrollment == practicionerAdd.Enrollment) { PracticionerRemove.Add(practicioner); } } _practicionersSelectedToAdd.Add(practicioner); _practicionersInThisGroup.Remove(practicioner); LoadPracticionerInThisGroup(); LoadPracticionerSelectedList(); } }
public void MapData(Project project, Practicioner practicioner, Assignment assignment, Coordinator coordinator) { ResponsibleProject responsibleProject = project.ResponsibleProject; LinkedOrganization linkedOrganization = project.LinkedOrganization; OfficeNumber = $"{assignment.IdAssignment}/{DateTime.Now.Year}"; DateOfGeneration = DateTime.Now; ResponsibleProjectName = $"{responsibleProject.Name} {responsibleProject.LastName}"; ResponsibleProjectCharge = responsibleProject.Charge; LinkedOrganizationName = linkedOrganization.Name; LinkedOrganizationAddress = linkedOrganization.Address; City = linkedOrganization.City.NameCity; State = linkedOrganization.State.NameState; PracticionerName = $"{practicioner.User.Name} {practicioner.User.LastName}"; PracticionerEnrollment = practicioner.Enrollment; ProjectName = project.NameProject; ProjectDuration = project.Duration; CoordinatorName = coordinator.User.Name; }
public void GetPracticioner() { List <Practicioner> data = new List <Practicioner> { new Practicioner { IdUser = 2, Enrollment = "zS18012149", Term = "FEBREO-JULIO 2021", Credits = 300 } }; DbSet <Practicioner> _mockSet = DbContextMock.GetQueryableMockDbSet(data, x => x.IdUser); ProfessionalPracticesContext _mockContext = DbContextMock.GetContext(_mockSet); UnitOfWork unitOfWork = new UnitOfWork(_mockContext); Practicioner practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.IdUser == 2); Assert.IsNotNull(practicioner); }
public void MapData(Project project, Practicioner practicioner, Assignment assignment, Coordinator coordinator) { Day = DateTime.Now.Day; Month = "Abril"; Year = DateTime.Now.Year; CoordinatorName = $"{coordinator.User.Name} {coordinator.User.LastName}"; PracticionerName = practicioner.User.Name; PracticionerEnrollment = practicioner.Enrollment; LinkedOrganizationName = project.LinkedOrganization.Name; StartingDate = assignment.StartTerm; ProjectDuration = project.Duration; MondaySchedule = ""; TuesdaySchedule = ""; WednesdaySchedule = ""; ThursdaySchedule = ""; FridaySchedule = ""; CoordinatorEmail = coordinator.User.Email; CoordinatorPhoneNumber = coordinator.User.PhoneNumber; CoordinatorCharge = "Coordinador de prácticas profesionales"; }
public async Task <HttpResponseMessage> Get() { var httpClient = new HttpClient(); var url = @"http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/all.xml?apikey=bbccdd"; var response = await httpClient.GetAsync(new Uri(url)); var content = await response.Content.ReadAsStreamAsync(); var reader = new XmlSerializer(typeof(feed)); var feeds = (feed)reader.Deserialize(content); var practioners = new List <Practicioner>(); try { foreach (var p in feeds.entry) { var practicioner = new Practicioner { Name = p.content.organisationSummary.name, AddressLine1 = (p.content.organisationSummary.address.addressLine.Length > 0) ? p.content.organisationSummary.address.addressLine[0] : String.Empty, AddressLine2 = (p.content.organisationSummary.address.addressLine.Length > 1) ? p.content.organisationSummary.address.addressLine[1] : String.Empty, AddressLine3 = (p.content.organisationSummary.address.addressLine.Length > 2) ? p.content.organisationSummary.address.addressLine[2] : String.Empty, AddressLine4 = (p.content.organisationSummary.address.addressLine.Length > 3) ? p.content.organisationSummary.address.addressLine[3] : String.Empty, AddressLine5 = (p.content.organisationSummary.address.addressLine.Length > 4) ? p.content.organisationSummary.address.addressLine[4] : String.Empty, PostCode = p.content.organisationSummary.address.postcode, Phone = p.content.organisationSummary.phone, Latitude = p.content.organisationSummary.geographicCoordinates.latitude, Longitude = p.content.organisationSummary.geographicCoordinates.longitude }; practioners.Add(practicioner); } } catch (Exception ex) { } return(this.Request.CreateResponse(HttpStatusCode.OK, practioners)); }
public async Task<HttpResponseMessage> Get() { var httpClient = new HttpClient(); var url = @"http://v1.syndication.nhschoices.nhs.uk/organisations/gppractices/all.xml?apikey=bbccdd"; var response = await httpClient.GetAsync(new Uri(url)); var content = await response.Content.ReadAsStreamAsync(); var reader = new XmlSerializer(typeof(feed)); var feeds = (feed)reader.Deserialize(content); var practioners = new List<Practicioner>(); try { foreach (var p in feeds.entry) { var practicioner = new Practicioner { Name = p.content.organisationSummary.name, AddressLine1 = (p.content.organisationSummary.address.addressLine.Length > 0) ? p.content.organisationSummary.address.addressLine[0] : String.Empty, AddressLine2 = (p.content.organisationSummary.address.addressLine.Length > 1) ? p.content.organisationSummary.address.addressLine[1] : String.Empty, AddressLine3 = (p.content.organisationSummary.address.addressLine.Length > 2) ? p.content.organisationSummary.address.addressLine[2] : String.Empty, AddressLine4 = (p.content.organisationSummary.address.addressLine.Length > 3) ? p.content.organisationSummary.address.addressLine[3] : String.Empty, AddressLine5 = (p.content.organisationSummary.address.addressLine.Length > 4) ? p.content.organisationSummary.address.addressLine[4] : String.Empty, PostCode = p.content.organisationSummary.address.postcode, Phone = p.content.organisationSummary.phone, Latitude = p.content.organisationSummary.geographicCoordinates.latitude, Longitude = p.content.organisationSummary.geographicCoordinates.longitude }; practioners.Add(practicioner); } } catch (Exception ex) { } return this.Request.CreateResponse(HttpStatusCode.OK, practioners); }
private void LoadPracticionerInformation() { ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); try { Practicioner practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.Enrollment == Enrollment); LabelPracticioner.Content = practicioner.User.Name + " " + practicioner.User.LastName; _project = unitOfWork.Practicioners.GetPracticionerInformationProject(Enrollment); LabelProject.Content = _project.NameProject; LabelOrganization.Content = _project.ResponsibleProject.Name + " " + _project.ResponsibleProject.LastName; TextBoxCumulativeHours.Text = unitOfWork.Practicioners.GetAccumulatedHours(Enrollment).ToString(); } catch (EntityException) { ShowExceptionDB(); } finally { unitOfWork.Dispose(); } }
private void ColocatePracticioner(string enrollment) { try { Practicioner = _unitOfWork.Practicioners.GetAllInformationPracticioner(enrollment); RadioButtonMen.IsChecked = Practicioner.User.Gender == Gender.MALE; RadioButtonWomen.IsChecked = !RadioButtonMen.IsChecked; if (Practicioner.User.UserStatus == UserStatus.ACTIVE) { ComboBoxPracticionerStatus.SelectedIndex = 0; } else { ComboBoxPracticionerStatus.SelectedIndex = 1; } CreatePeriod(Practicioner.Term); } catch (SqlException) { _unitOfWork.Dispose(); CatchDBException(); } }
private void LoadPracticionerInformation() { Practicioner practicioner = new Practicioner(); ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); try { practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.Enrollment.Equals(_enrollment)); textBlockProjectName.Text = unitOfWork.Practicioners.GetPracticionerProject(_enrollment); labelEnrollment.Content = practicioner.Enrollment; labelEmail.Content = practicioner.User.Email; labelName.Content = practicioner.User.Name + " " + practicioner.User.LastName; labelPhone.Content = practicioner.User.PhoneNumber; } catch (EntityException) { ShowException(); } finally { unitOfWork.Dispose(); } }
public void DetermineIfPracticionerExists_Exists() { List <Practicioner> data = new List <Practicioner> { new Practicioner { Enrollment = "zS18012149", Credits = 300, Group = new Group { IdGroup = 1, Nrc = "12345" }, IdUser = 1 } }; DbSet <Practicioner> mockSet = DbContextMock.GetQueryableMockDbSet(data, x => x.Enrollment); ProfessionalPracticesContext mockContext = DbContextMock.GetContext(mockSet); UnitOfWork unitOfWork = new UnitOfWork(mockContext); Practicioner practicioner = unitOfWork.Practicioners.FindFirstOccurence(Practicioner => Practicioner.Enrollment == "zS18012149"); Assert.IsNotNull(practicioner); }
private void SaveAssignmentOffice() { ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); try { string assignmentOfficeFilePath = FileExplorer.Show("Guardar oficio de asignación"); string acceptanceOfficeFilePath = FileExplorer.Show("Guardar oficio de aceptación"); Coordinator coordinator = unitOfWork.Coordinators.FindFirstOccurence(c => c.User.UserStatus == UserStatus.ACTIVE); _selectedProject = unitOfWork.Projects.Get(_selectedProject.IdProject); _selectedPracticioner = unitOfWork.Practicioners.Get(_selectedPracticioner.Enrollment); OfficeOfAcceptance officeOfAcceptance = new OfficeOfAcceptance { DateOfAcceptance = DateTime.Now, RouteSave = acceptanceOfficeFilePath }; _assignment = new Assignment { CompletionTerm = "", DateAssignment = DateTime.Now, RouteSave = assignmentOfficeFilePath, StartTerm = _selectedProject.Term, Status = AssignmentStatus.Assigned, OfficeOfAcceptance = officeOfAcceptance, IdProject = _selectedProject.IdProject, Enrollment = _selectedPracticioner.Enrollment }; AcceptanceOfficeTemplate acceptanceOfficeTemplate = new AcceptanceOfficeTemplate(); acceptanceOfficeTemplate.MapData(_selectedProject, _selectedPracticioner, _assignment, coordinator); AssignmentOfficeTemplate assignmentOfficeTemplate = new AssignmentOfficeTemplate(); assignmentOfficeTemplate.MapData(_selectedProject, _selectedPracticioner, _assignment, coordinator); DocumentGenerator documentGenerator = new DocumentGenerator(); documentGenerator.CreateAcceptanceOfficeDocument($"{_assignment.RouteSave}", acceptanceOfficeTemplate); documentGenerator.CreateAssignmentOfficeTemplate($"{_assignment.OfficeOfAcceptance.RouteSave}", assignmentOfficeTemplate); _selectedProject.QuantityPracticingAssing += 1; if (_selectedProject.QuantityPracticingAssing == _selectedProject.QuantityPracticing) { _selectedProject.Status = ProjectStatus.FILLED; } List <RequestProject> requestedProjects = _selectedPracticioner.Requests; foreach (RequestProject requestedProject in requestedProjects) { if (requestedProject.IdProject == _selectedProject.IdProject) { requestedProject.RequestStatus = RequestStatus.APROVED; } else { requestedProject.RequestStatus = RequestStatus.DENIED; } } unitOfWork.Assignments.Add(_assignment); unitOfWork.Complete(); MessageBox.Show("Proyecto asignado de forma exitosa"); } catch (EntityException) { MessageBox.Show("Ha ocurrido un error en la conexión con la base de datos", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error); } catch (SqlException) { MessageBox.Show("Ha ocurrido un error en la conexión con la base de datos", "Consulta Fallida", MessageBoxButton.OK, MessageBoxImage.Error); } catch (NullReferenceException) { MessageBox.Show("Ocurrió un error al intentar generar el oficio de asignación; por favor, intente más tarde", "Guardado Fallido", MessageBoxButton.OK, MessageBoxImage.Error); } catch (COMException) { MessageBox.Show("Ocurrió un error al intentar generar el oficio de asignación, debido a que la ruta o el nombre del archivo que especificó no es válido; por favor, intente más tarde", "Guardado Fallido", MessageBoxButton.OK, MessageBoxImage.Error); } catch (ObjectDisposedException) { MessageBox.Show("Ocurrió un error al intentar generar el oficio de asignación; por favor, intente más tarde", "Guardado Fallido", MessageBoxButton.OK, MessageBoxImage.Error); } finally { unitOfWork.Dispose(); GoBackToCoordinatorMenu(); } }
private Practicioner GetSelectedPracticioner() { Practicioner practicioner = ((Practicioner)ListViewPracticioners.SelectedItem); return(practicioner); }