public void UpdateCerereTest() { try { var cerereUpdate = new CerereMedicPacient { TipComponenta = TipComponenta.Trombocite.ToString(), DataDepunere = DateTime.Now, DataServire = DateTime.Now, Stare = "TEST" }; _cerereMedicPacientRepository.Add(cerereUpdate); Assert.IsTrue(String.Compare(cerereUpdate.TipComponenta, TipComponenta.Trombocite.ToString(), StringComparison.Ordinal) == 0); cerereUpdate.TipComponenta = TipComponenta.Plasma.ToString(); _cerereMedicPacientRepository.Update(cerereUpdate); cerereUpdate = _cerereMedicPacientRepository.Find(cerereUpdate.Id); Assert.IsTrue(String.Compare(cerereUpdate.TipComponenta, TipComponenta.Plasma.ToString(), StringComparison.Ordinal) == 0); } catch (Exception) { Assert.Fail(); } }
public void DeleteCerereTest() { var size = _cerereMedicPacientRepository.GetAll().Count(); try { var cerereTest1 = new CerereMedicPacient { TipComponenta = TipComponenta.Trombocite.ToString(), DataDepunere = DateTime.Now, DataServire = DateTime.Now, Stare = "TEST" }; var cerereTest2 = new CerereMedicPacient { TipComponenta = TipComponenta.Plasma.ToString(), DataDepunere = DateTime.Now, DataServire = DateTime.Now, Stare = "TEST" }; _cerereMedicPacientRepository.Add(cerereTest2); _cerereMedicPacientRepository.Add(cerereTest1); _cerereMedicPacientRepository.Delete(cerereTest2.Id); _cerereMedicPacientRepository.Delete(cerereTest1.Id); } catch (Exception) { Assert.Fail(); } var size2 = _cerereMedicPacientRepository.GetAll().Count(); Assert.IsTrue(size2 == size); try { var cerereTest1 = new CerereMedicPacient { TipComponenta = TipComponenta.Trombocite.ToString(), DataDepunere = DateTime.Now, DataServire = DateTime.Now, Stare = "TEST" }; _cerereMedicPacientRepository.Delete(cerereTest1.Id); Assert.Fail(); } catch (Exception) { // Test passed } }
public CerereViewModel(CerereMedicPacient cerere) { Id = cerere.Id; IdPacient = cerere.IdPacient; IdMedic = cerere.IdMedic; IdGrupaDeSange = cerere.GrupaDeSange; TipComponenta = cerere.TipComponenta; DataDepunere = cerere.DataDepunere; DataServire = cerere.DataServire; GrupaDeSange = cerere.GrupaDeSangeObj; Pacient = cerere.PacientObj; Medic = cerere.MedicObj; Stare = cerere.Stare; TipComponenta = cerere.TipComponenta; }
public void Validate(CerereMedicPacient entity) { var errorMessage = ""; if (string.IsNullOrWhiteSpace(entity.TipComponenta)) { errorMessage += "Tipul componentei trebuie setat! \n"; } if (string.IsNullOrWhiteSpace(entity.Stare)) { errorMessage += "Starea nu poate fi vida! \n"; } if (!string.IsNullOrWhiteSpace(errorMessage)) { throw new ValidationException(errorMessage); } }
public void FindCerereTest() { try { var cerereTest1 = new CerereMedicPacient { TipComponenta = TipComponenta.Trombocite.ToString(), DataDepunere = DateTime.Now, DataServire = DateTime.Now, Stare = "TEST" }; _cerereMedicPacientRepository.Add(cerereTest1); var cerereFind = _cerereMedicPacientRepository.Find(cerereTest1.Id); Assert.IsTrue(cerereFind.Id == cerereTest1.Id); Assert.IsTrue(String.Compare(cerereFind.TipComponenta, cerereTest1.TipComponenta, StringComparison.Ordinal) == 0); } catch (Exception) { Assert.Fail(); } }
public void Save() { if (String.IsNullOrEmpty(NumePacient) || String.IsNullOrEmpty(PrenumePacient) || SelectedGrupa == null) { MessageBox.Show("Please make sure you completed all the fields!", "Error", MessageBoxButton.OK); } else { try { Pacient Pacient = AppService.Instance.PacientService.GetPacientByFullName(NumePacient, PrenumePacient).First(); CerereViewModel.IdMedic = AppSettings.LoggedMedic.Id; CerereViewModel.IdPacient = Pacient.Id; CerereViewModel.IdGrupaDeSange = SelectedGrupa.Id; CerereViewModel.Medic = AppSettings.LoggedMedic; CerereViewModel.Pacient = Pacient; CerereViewModel.TipComponenta = SelectedTip; CerereViewModel.GrupaDeSange = SelectedGrupa; CerereViewModel.Stare = SelectedStare; CerereViewModel.DataDepunere = DateTime.Now; if (SelectedStare.CompareTo(StariPosibile.First()) != 0) { CerereViewModel.DataServire = DateTime.Now; } else { CerereViewModel.DataServire = DateTime.Parse("1970-01-01 00:00:00"); } var Cerere = new CerereMedicPacient() { Id = CerereViewModel.Id, IdPacient = CerereViewModel.IdPacient, IdMedic = CerereViewModel.IdMedic, GrupaDeSange = CerereViewModel.IdGrupaDeSange, TipComponenta = CerereViewModel.TipComponenta, Stare = CerereViewModel.Stare, DataDepunere = CerereViewModel.DataDepunere, DataServire = CerereViewModel.DataServire, GrupaDeSange1 = CerereViewModel.GrupaDeSange, Medic = CerereViewModel.Medic, Pacient = CerereViewModel.Pacient }; if (CerereViewModel.Id == 0) { AppService.Instance.CerereService.Add(Cerere); CerereAdded?.Invoke(this, Cerere); MessageBox.Show("Cerere added successfully!", "Success", MessageBoxButton.OK); } else { AppService.Instance.CerereService.Update(Cerere); CerereUpdated?.Invoke(this, Cerere); MessageBox.Show("Cerere updated successfully!", "Success", MessageBoxButton.OK); } } catch (ServiceException e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK); } catch (InvalidOperationException) { MessageBox.Show("Pacient not found or there is a problem with the database", "Error", MessageBoxButton.OK); } } }
public void Update(CerereMedicPacient entity) { _repository.Update(entity); }
public void Add(CerereMedicPacient entity) { _repository.Add(entity); AppService.Instance.AnuntDonatorService.BatchAdd((int)entity.GrupaDeSange, "Salut, avem nevoie de sange", entity.PacientObj); }
public void InitializeTest() { _testCerereMedicPacient = new CerereMedicPacient(); }
public void CerereValidatorTest() { try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = "", Stare = "TEST" }; _cerereMedicPacientValidator.Validate(cerereTest); Assert.Fail(); } catch (ValidationException) { // Test passed } try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = TipComponenta.GlobuleRosii.ToString(), Stare = "" }; _cerereMedicPacientValidator.Validate(cerereTest); Assert.Fail(); } catch (ValidationException) { // Test passed } try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = "", Stare = "" }; _cerereMedicPacientValidator.Validate(cerereTest); Assert.Fail(); } catch (ValidationException) { // Test passed } try { var cerereTest = new CerereMedicPacient { Id = 1, IdMedic = 2, IdPacient = 3, TipComponenta = TipComponenta.GlobuleRosii.ToString(), Stare = "TEST" }; _cerereMedicPacientValidator.Validate(cerereTest); // Test passed } catch (ValidationException) { Assert.Fail(); } }
private void Deservire() { if (SelectedCerere == null) { MessageBox.Show("Selecteaza o cerere.", "Atentie", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (SelectedCerere.Stare != "InAsteptare") { MessageBox.Show("Selecteaza o cerere in asteptare.", "Atentie", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (SelectedComponenta == null) { MessageBox.Show("Selecteaza o componenta.", "Atentie", MessageBoxButton.OK, MessageBoxImage.Information); } else { // modifica cererea try { var idDonator = SelectedComponenta.Donatie.IdDonator; var cerere = new CerereMedicPacient(); cerere.Id = SelectedCerere.Id; cerere.IdPacient = SelectedCerere.IdPacient; cerere.IdMedic = SelectedCerere.IdMedic; cerere.DataDepunere = SelectedCerere.DataDepunere; cerere.DataServire = DateTime.Now; cerere.GrupaDeSange = SelectedCerere.IdGrupaDeSange; cerere.TipComponenta = SelectedCerere.TipComponenta; cerere.Stare = StareCerere.IncheiataPozitiv.ToString(); AppService.Instance.CerereService.Update(cerere); SelectedCerere.Stare = StareCerere.IncheiataPozitiv.ToString(); // modifica componenta var componenta = new Componenta(); componenta.Id = SelectedComponenta.Id; componenta.TipComponenta = SelectedComponenta.TipComponenta; componenta.IdDonatie = SelectedComponenta.IdDonatie; componenta.DataDepunere = SelectedComponenta.DataDepunere; componenta.IdPrimitor = SelectedCerere.IdPacient; componenta.Stare = StareComponenta.Donata.ToString(); AppService.Instance.ComponentaService.Update(componenta); Componente.Remove(SelectedComponenta); // adauga anunt la donator var anunt = new AnuntDonator(); anunt.DataAnunt = DateTime.Now; anunt.IdDonator = idDonator; anunt.TipAnuntDonator = TipAnuntDonator.Info.ToString(); anunt.Mesaj = "Salut, \n componenta ta de tipul:" + componenta.TipComponenta + " a fost donata cu succes!"; AppService.Instance.AnuntDonatorService.Add(anunt); MessageBox.Show("Componenta a fost distribuita cu succes!", "Informare", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Atentie", MessageBoxButton.OK, MessageBoxImage.Information); } } } } }