Exemple #1
0
        public void TestUpdateCerere()
        {
            int    count  = medicService.GetAllCereri().Count;
            Cerere cerere = new Cerere("xx-xx-xxxx", 1, 1, 1, 1, false, null, GrupaSange.AII, TipRh.Negativ);

            medicService.AddCerere(cerere, "ioana", new List <Pacient>());
            Cerere cerereSalvata = medicService.GetCereriByMedic("ioana").Where(c => c.Data.Equals("xx-xx-xxxx") && c.Grupa.Equals(GrupaSange.AII) && c.RH.Equals(TipRh.Negativ)).FirstOrDefault();

            Assert.AreEqual(count + 1, medicService.GetAllCereri().Count);
            try
            {
                medicService.AddCerere(cerereSalvata, "ioana", new List <Pacient>());
            }
            catch (Exception ex)
            {
                Assert.AreEqual(count + 1, medicService.GetAllCereri().Count);
            }

            cerereSalvata.Efectuata      = true;
            cerereSalvata.CantitateSange = 100;
            medicService.UpdateCerere(cerereSalvata);
            cerereSalvata = medicService.GetCereriByMedic("ioana").Where(c => c.Data.Equals("xx-xx-xxxx") && c.Grupa.Equals(GrupaSange.AII) && c.RH.Equals(TipRh.Negativ)).FirstOrDefault();

            Assert.AreEqual(true, cerereSalvata.Efectuata);
            Assert.AreEqual(100, cerereSalvata.CantitateSange);

            medicService.DeleteCerere(cerereSalvata);
            Assert.AreEqual(count, medicService.GetAllCereri().Count());
        }
Exemple #2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxRH.SelectedItem == null || comboBoxGrupa.SelectedItem == null || comboBoxPr == null)
                {
                    throw new Exception("Trebuie selectata grupa, Rh-ul si gradul de urgenta!");
                }

                if (comboBoxGrupa.Enabled)
                {
                    Cerere cerere = BuildCerereSave();
                    serviceMedic.AddCerere(cerere, usernameMedic, GetPacientiSelectati());
                }
                else
                {
                    Cerere cerere = BuildCerereUpdate();
                    serviceMedic.UpdateCerere(cerere);
                }
                tabControl1.SelectedTab = tabPage2;
                Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Eroare!", MessageBoxButtons.OK);
            }
        }