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(); } }
private bool AddDocument() { try { ProfessionalPracticesContext professionalPracticesContext = new ProfessionalPracticesContext(); UnitOfWork unitOfWork = new UnitOfWork(professionalPracticesContext); ActivityPracticioner activityPracticionerUpdate = unitOfWork.ActivityPracticioners.Get(_activityPracticioner.IdActivityPracticioner); activityPracticionerUpdate.Answer = TextBoxAnswer.Text; Document documentUpdate = unitOfWork.Documents.Get(_document.IdDocument); documentUpdate.Name = _document.Name; documentUpdate.RouteSave = _document.RouteSave; DateTime deliveryDate = DateTime.Now; documentUpdate.DeliveryDate = deliveryDate; activityPracticionerUpdate.Activity.ActivityStatus = _activityPracticioner.Activity.ActivityStatus; int rowsAffected = unitOfWork.Complete(); unitOfWork.Dispose(); return(rowsAffected >= 0 || rowsAffected <= 3); } catch (SqlException) { return(false); } catch (EntityException) { return(false); } }
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); }
public void AddReport() { ActivityPracticioner updateActivityPracticioner = _unitOfWork.ActivityPracticioners.Get(9); updateActivityPracticioner.Observation = "Muy bien realizado"; updateActivityPracticioner.Qualification = 10; updateActivityPracticioner.ActivityPracticionerStatus = ActivityPracticionerStatus.QUALIFIED; int expected = 1; int actual = _data.Count; Assert.AreEqual(expected, actual); }
private bool UpdateActivityPracticioner(UnitOfWork unitOfWork) { ActivityPracticioner updateActivityPracticioner = unitOfWork.ActivityPracticioners.Get(_activityPracticioner.IdActivityPracticioner); updateActivityPracticioner.Observation = _activityPracticioner.Observation; updateActivityPracticioner.Qualification = _activityPracticioner.Qualification; updateActivityPracticioner.ActivityPracticionerStatus = ActivityPracticionerStatus.QUALIFIED; int rowsAffected = unitOfWork.Complete(); unitOfWork.Dispose(); return(rowsAffected == 1); }
public bool SearchDocument(string enrollment) { ActivityPracticioner activityPracticioners = _context.Set <ActivityPracticioner>().Include(Act => Act.Activity).SingleOrDefault(ActivityPracticioner => ActivityPracticioner.Enrollment == enrollment && ActivityPracticioner.Activity.ActivityType == ActivityType.MonthlyReport && ActivityPracticioner.Activity.ActivityStatus == ActivityStatus.ACTIVE); Document document = _context.Set <Document>().SingleOrDefault(Document => Document.IdActivityPracticioner == activityPracticioners.IdActivityPracticioner); if (!object.ReferenceEquals(null, document)) { return(true); } return(false); }
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); }
public bool InitializeActivity(ActivityPracticioner activityPracticionerReceived, string titleReport) { TextBlockNameReport.Text = titleReport; _activityPracticioner = activityPracticionerReceived; LabelName.Content = "Actividad: " + _activityPracticioner.Activity.Name + " Valor: " + _activityPracticioner.Activity.ValueActivity.ToString(); LabelDate.Content = "Fecha de Inicio: " + _activityPracticioner.Activity.StartDate + " Fecha de Finalización: " + _activityPracticioner.Activity.FinishDate; TextBlockDescription.Text = "Instrucciones: " + _activityPracticioner.Activity.Description; if (string.IsNullOrWhiteSpace(_activityPracticioner.Activity.Description)) { TextBlockDescription.Text = "Instrucciones: Ninguna"; } return(ObteinDocument()); }
private void PracticionerListViewSelectionChanged(object listViewPracticioner, SelectionChangedEventArgs selectionChanged) { TextBoxObservation.Text = null; TextBoxQualification.Text = null; int itemSelected = ListViewPracticioners.SelectedIndex; _activityPracticioner = _activityPracticioners.ElementAt(itemSelected); if (_activityPracticioner != null) { _document = _documents.FirstOrDefault(Document => Document.IdActivityPracticioner == _activityPracticioner.IdActivityPracticioner); if (_document != null) { LabelNameDocument.Content = _document.Name; TextBlockAnswer.Text = _activityPracticioner.Answer; if (!string.IsNullOrWhiteSpace(_document.RouteSave)) { ButtonDownloadFile.IsEnabled = true; ButtonQualification.IsEnabled = true; TextBoxObservation.IsReadOnly = false; TextBoxQualification.IsReadOnly = false; TextBoxObservation.Text = _activityPracticioner.Observation; TextBoxQualification.Text = _activityPracticioner.Qualification.ToString(); } else { ButtonDownloadFile.IsEnabled = false; ButtonQualification.IsEnabled = true; TextBoxObservation.IsReadOnly = false; TextBoxQualification.IsReadOnly = false; TextBoxObservation.Text = _activityPracticioner.Observation; TextBoxQualification.Text = _activityPracticioner.Qualification.ToString(); } } else { ButtonDownloadFile.IsEnabled = false; ButtonQualification.IsEnabled = false; TextBoxObservation.IsReadOnly = true; TextBoxQualification.IsReadOnly = true; TextBoxObservation.Text = _activityPracticioner.Observation; TextBoxQualification.Text = _activityPracticioner.Qualification.ToString(); } } }
private void PartialReportItemsControlMouseDoubleClicked(object listViewReport, RoutedEventArgs routedEventArgs) { int itemSelect = ((ListView)listViewReport).SelectedIndex; ActivityPracticioner activityPracticioner = _activityPracticioners.ElementAt(itemSelect); if (activityPracticioner != null) { ReportAdd partialReportAdd = new ReportAdd(); ReportAdd.Enrollment = Enrollment; if (partialReportAdd.InitializeActivity(activityPracticioner, _activityTypeReport)) { partialReportAdd.Show(); Close(); } else { MessageBox.Show("No se pudo obtener información de la actividad. Intente más tarde", "No se puede acceder", MessageBoxButton.OK, MessageBoxImage.Warning); } } }