コード例 #1
0
        public IActionResult Seed()
        {
            var d1 = new Doctor
            {
                IdDoctor  = 1,
                FirstName = "Piotr",
                LastName  = "Juszkiewicz",
                Email     = "*****@*****.**"
            };

            _cfc.Doctors.Add(d1);

            var d2 = new Doctor
            {
                IdDoctor  = 2,
                FirstName = "Jan",
                LastName  = "Kocisz",
                Email     = "*****@*****.**"
            };

            _cfc.Doctors.Add(d2);

            var p1 = new Patient
            {
                IdPatient = 1,
                FirstName = "Tomasz",
                LastName  = "Lusztyk",
                BirthDate = DateTime.Now
            };

            _cfc.Patients.Add(p1);

            var p2 = new Patient
            {
                IdPatient = 2,
                FirstName = "Grzegorz",
                LastName  = "Matczak",
                BirthDate = DateTime.Now
            };

            _cfc.Patients.Add(p2);

            var pr1 = new Prescription
            {
                IdPrescription = 1,
                Date           = DateTime.Now,
                DueDate        = DateTime.Now,
                IdPatient      = 1,
                IdDoctor       = 1
            };

            _cfc.Prescriptions.Add(pr1);

            var pr2 = new Prescription
            {
                IdPrescription = 2,
                Date           = DateTime.Now,
                DueDate        = DateTime.Now,
                IdPatient      = 2,
                IdDoctor       = 2
            };

            _cfc.Prescriptions.Add(pr2);

            var m1 = new Medicament
            {
                IdMedicament = 1,
                Name         = "medicament1",
                Description  = "description1",
                Type         = "type1"
            };

            _cfc.Medicaments.Add(m1);

            var m2 = new Medicament
            {
                IdMedicament = 2,
                Name         = "medicament2",
                Description  = "description2",
                Type         = "type2"
            };

            _cfc.Medicaments.Add(m2);

            var pm1 = new Prescription_Medicament
            {
                IdMedicament   = 1,
                IdPrescription = 1,
                Dose           = 1,
                Details        = "details1"
            };

            _cfc.Prescription_Medicaments.Add(pm1);

            var pm2 = new Prescription_Medicament
            {
                IdMedicament   = 2,
                IdPrescription = 2,
                Dose           = 2,
                Details        = "details2"
            };

            _cfc.Prescription_Medicaments.Add(pm2);

            return(Ok("Seed done"));
        }
コード例 #2
0
        public void Seed()
        {
            var doc1 = new Doctor
            {
                IdDoctor  = 1,
                FirstName = "Wasiej",
                LastName  = "Maciak",
                Email     = "*****@*****.**"
            };

            var doc2 = new Doctor
            {
                IdDoctor  = 2,
                FirstName = "Silip",
                LastName  = "Ftachurski",
                Email     = "*****@*****.**"
            };

            _context.Doctors.Add(doc1);
            _context.Doctors.Add(doc2);

            var pat1 = new Patient
            {
                IdPatient = 1,
                FirstName = "Maciej",
                LastName  = "Wasiak",
                Birthdate = DateTime.Now
            };

            var pat2 = new Patient
            {
                IdPatient = 2,
                FirstName = "Filip",
                LastName  = "Stachurski",
                Birthdate = DateTime.Now
            };

            _context.Patients.Add(pat1);
            _context.Patients.Add(pat2);

            var pre1 = new Prescription
            {
                IdPrescritpion = 1,
                Date           = DateTime.Now,
                DueDate        = DateTime.Now,
                IdPatient      = 1,
                IdDoctor       = 2
            };

            var pre2 = new Prescription
            {
                IdPrescritpion = 2,
                Date           = DateTime.Now,
                DueDate        = DateTime.Now,
                IdPatient      = 2,
                IdDoctor       = 1
            };

            _context.Prescriptions.Add(pre1);
            _context.Prescriptions.Add(pre2);

            var med1 = new Medicament
            {
                IdMedicament = 1,
                Name         = "wasiakozol",
                Description  = "na brak weny programistycznej",
                Type         = "silnie uzalezniajacy"
            };

            var med2 = new Medicament
            {
                IdMedicament = 2,
                Name         = "klonozepam",
                Description  = "na leb",
                Type         = "silnie uzalezniajacy"
            };

            _context.Medicaments.Add(med1);
            _context.Medicaments.Add(med2);

            var pm1 = new Prescription_Medicament
            {
                IdMedicament   = 1,
                IdPrescritpion = 1,
                Dose           = 1000,
                Details        = "brak"
            };

            var pm2 = new Prescription_Medicament
            {
                IdMedicament   = 2,
                IdPrescritpion = 2,
                Dose           = 10,
                Details        = "brak"
            };

            _context.Prescriptions_Medicaments.Add(pm1);
            _context.Prescriptions_Medicaments.Add(pm2);
        }
コード例 #3
0
        public IActionResult index()
        {
            var context = new DefaultDbContext();
            var doctor1 = new Doctor
            {
                FirstName = "Jarek",
                LastName  = "Dokczyński",
                Email     = "*****@*****.**"
            };
            var doctor2 = new Doctor
            {
                FirstName = "Darek",
                LastName  = "Leczynski",
                Email     = "*****@*****.**"
            };
            var doctor3 = new Doctor
            {
                FirstName = "Marek",
                LastName  = "Dietczynski",
                Email     = "*****@*****.**"
            };

            var pacjet1 = new Patient
            {
                FirstName = "Pan",
                LastName  = "Kotek",
            };

            var pacjet2 = new Patient
            {
                FirstName = "Byl",
                LastName  = "Chorym",
            };

            var pacjet3 = new Patient
            {
                FirstName = "Lezal",
                LastName  = "Lozeczku",
            };

            var med1 = new Medicament
            {
                Name        = "Vicodin",
                Type        = "Painkiller",
                Description = "Silny lek przeciwbólowy"
            };

            var med2 = new Medicament
            {
                Name        = "Rutinoscorbin",
                Type        = "Suplement",
                Description = "Suplement wspomagający"
            };

            var med3 = new Medicament
            {
                Name        = "Penicylina",
                Type        = "Antibiotic",
                Description = "Popularny antybiotyk"
            };

            var pres1 = new Prescription
            {
                Patient = pacjet1,
                Doctor  = doctor1,
                DueDate = DateTime.Parse("2020-11-01"),
                Date    = DateTime.Now
            };

            var pres2 = new Prescription
            {
                Patient = pacjet2,
                Doctor  = doctor2,
                DueDate = DateTime.Parse("2020-11-01"),
                Date    = DateTime.Now
            };

            var pres1med1 = new Prescription_Medicament
            {
                Medicament   = med1,
                Prescription = pres1,
                Dose         = 100,
            };

            var pres2med1 = new Prescription_Medicament
            {
                Medicament   = med1,
                Prescription = pres2,
                Dose         = 200
            };

            var pres2med2 = new Prescription_Medicament
            {
                Medicament   = med2,
                Prescription = pres2
            };

            context.Add(doctor1);
            context.Add(doctor2);
            context.Add(doctor3);
            context.Add(pacjet1);
            context.Add(pacjet2);
            context.Add(pacjet3);
            context.Add(med1);
            context.Add(med2);
            context.Add(med3);
            context.Add(pres1);
            context.Add(pres2);
            context.Add(pres1med1);
            context.Add(pres2med1);
            context.Add(pres2med2);

            context.SaveChanges();

            return(Ok("Seeded"));
        }
コード例 #4
0
        public void seed()
        {
            var con     = _context;
            var doctor1 = new Doctor
            {
                firstName = "Jan",
                lastName  = "Janiak",
                email     = "*****@*****.**"
            };

            con.Doctors.Add(doctor1);
            var doctor2 = new Doctor
            {
                firstName = "Jerzy",
                lastName  = "Jeż",
                email     = "jerzy@jeż.pl"
            };

            con.Doctors.Add(doctor2);

            var patient1 = new Patient
            {
                firstName = "Lech",
                lastName  = "Lach",
                birthDate = DateTime.ParseExact("2000-05-08", "yyyy-MM-dd",
                                                System.Globalization.CultureInfo.InvariantCulture)
            };

            con.Patients.Add(patient1);
            var patient2 = new Patient
            {
                firstName = "Andrzej",
                lastName  = "Jedynak",
                birthDate = DateTime.ParseExact("2001-01-01", "yyyy-MM-dd",
                                                System.Globalization.CultureInfo.InvariantCulture)
            };

            con.Patients.Add(patient2);

            var med1 = new Medicament
            {
                name        = "Amol",
                description = "lek ziolowy",
                type        = "plyn"
            };

            con.Medicaments.Add(med1);
            var med2 = new Medicament
            {
                name        = "Ketanol",
                description = "lek przeciwbolowy",
                type        = "tabletka"
            };

            con.Medicaments.Add(med2);

            var pre1 = new Prescription
            {
                date = DateTime.ParseExact("2011-01-01", "yyyy-MM-dd",
                                           System.Globalization.CultureInfo.InvariantCulture),
                dueDate = DateTime.ParseExact("2012-01-01", "yyyy-MM-dd",
                                              System.Globalization.CultureInfo.InvariantCulture),
                patient = patient1,
                doctor  = doctor1
            };

            con.Prescriptions.Add(pre1);
            var pre2 = new Prescription
            {
                date = DateTime.ParseExact("2013-01-01", "yyyy-MM-dd",
                                           System.Globalization.CultureInfo.InvariantCulture),
                dueDate = DateTime.ParseExact("2014-01-01", "yyyy-MM-dd",
                                              System.Globalization.CultureInfo.InvariantCulture),
                patient = patient2,
                doctor  = doctor2
            };

            con.Prescriptions.Add(pre2);

            var preMed1 = new Prescription_Medicament
            {
                idMedicament = 1,
                prescription = pre1,
                medicament   = med1,
                dose         = 1,
                details      = "detale"
            };

            con.Prescription_Medicaments.Add(preMed1);
            var preMed2 = new Prescription_Medicament
            {
                idMedicament = 2,
                prescription = pre2,
                medicament   = med2,
                dose         = 2,
                details      = "detale2"
            };

            con.Prescription_Medicaments.Add(preMed2);
            con.SaveChanges();
        }
コード例 #5
0
        public IActionResult RandomSeed()
        {
            try
            {
                var doc1 = new Doctor();
                doc1.FirstName    = "Jan";
                doc1.LastName     = "Kowalski";
                doc1.Email        = "*****@*****.**";
                doc1.Prescription = new List <Prescription>();

                var pat1 = new Patient();
                pat1.FirstName    = "Zawsze";
                pat1.LastName     = "Chory";
                pat1.BithDate     = DateTime.Now.AddYears(-20);
                pat1.Prescription = new List <Prescription>();

                var med1 = new Medicament();
                med1.Description             = "Na ciągłe choroby";
                med1.Name                    = "Maść_Na_Choroby i tym podobne";
                med1.Type                    = "Maść";
                med1.PrescriptionXMedicament = new List <Prescription_Medicament>();

                db.Doctor.Add(doc1);
                db.Patient.Add(pat1);
                db.Medicament.Add(med1);
                db.SaveChanges();

                var pres1 = new Prescription();
                pres1.Doctor    = doc1;
                pres1.Patient   = pat1;
                pres1.IdPatient = db.Patient.Where(e => e.LastName == pat1.LastName && e.FirstName == pat1.FirstName && e.BithDate == pat1.BithDate).First().IdPatient;
                pres1.IdDoctor  = db.Doctor.Where(e => e.LastName == doc1.LastName && e.FirstName == doc1.FirstName && e.Email == doc1.Email).First().IdDoctor;
                pres1.Date      = DateTime.Now;
                pres1.DueDate   = DateTime.Now.AddDays(20);
                pres1.PrescriptionXMedicament = new List <Prescription_Medicament>();

                db.Prescription.Add(pres1);
                db.SaveChanges();
                doc1.Prescription.Add(pres1);
                pat1.Prescription.Add(pres1);

                db.Update(doc1);
                db.Update(pat1);
                db.SaveChanges();

                var presXmedi1 = new Prescription_Medicament();
                presXmedi1.Details        = "Przecena 10%, 3szt po 10 użyć ";
                presXmedi1.Medicament     = med1;
                presXmedi1.IdMedicament   = db.Medicament.Where(e => e.Name == med1.Name && e.Description == med1.Description && e.Type == med1.Type).First().IdMedicament;
                presXmedi1.Prescription   = pres1;
                presXmedi1.IdPrescription = db.Prescription.Where(e => e.IdDoctor == pres1.IdDoctor && e.IdPatient == pres1.IdPatient).First().IdPrescription;

                db.Prescription_Medicaments.Add(presXmedi1);
                db.SaveChanges();
                pres1.PrescriptionXMedicament.Add(presXmedi1);
                med1.PrescriptionXMedicament.Add(presXmedi1);

                db.Update(pres1);
                db.Update(med1);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(NotFound("cos poszlo nie tak\n" + e));
            }
            return(Ok("Chaos"));
        }
コード例 #6
0
ファイル: EfDrugsDb.cs プロジェクト: s18727/cw11
        public void Seed()
        {
            var doctor1 = new Doctor
            {
                IdDoctor  = 1,
                FirstName = "Andrzej",
                LastName  = "Grabowski",
                Email     = "*****@*****.**"
            };

            var doctor2 = new Doctor
            {
                IdDoctor  = 2,
                FirstName = "Paulina",
                LastName  = "Mono",
                Email     = "*****@*****.**"
            };

            _context.Doctors.Add(doctor1);
            _context.Doctors.Add(doctor2);

            var patient1 = new Patient
            {
                IdPatient = 1,
                FirstName = "Andrzej",
                LastName  = "Nowak",
                Birthdate = DateTime.Now
            };

            var patient2 = new Patient
            {
                IdPatient = 2,
                FirstName = "Karol",
                LastName  = "Banan",
                Birthdate = DateTime.Now
            };

            _context.Patients.Add(patient1);
            _context.Patients.Add(patient2);

            var prescription1 = new Prescription
            {
                IdPrescritpion = 1,
                Date           = DateTime.Now,
                DueDate        = DateTime.Now,
                IdPatient      = 1,
                IdDoctor       = 2
            };

            var prescription2 = new Prescription
            {
                IdPrescritpion = 2,
                Date           = DateTime.Now,
                DueDate        = DateTime.Now,
                IdPatient      = 2,
                IdDoctor       = 1
            };

            _context.Prescriptions.Add(prescription1);
            _context.Prescriptions.Add(prescription2);

            var medicament1 = new Medicament
            {
                IdMedicament = 1,
                Name         = "C",
                Description  = "wzmocnienie",
                Type         = "profilaktyczny"
            };

            var medicament2 = new Medicament
            {
                IdMedicament = 2,
                Name         = "apap",
                Description  = "na ból głowy",
                Type         = "przeciwbólowy"
            };

            _context.Medicaments.Add(medicament1);
            _context.Medicaments.Add(medicament2);

            var prescription_medicament1 = new Prescription_Medicament
            {
                IdMedicament   = 1,
                IdPrescritpion = 1,
                Dose           = 100,
                Details        = "-"
            };

            var prescription_medicament2 = new Prescription_Medicament
            {
                IdMedicament   = 2,
                IdPrescritpion = 2,
                Dose           = 600,
                Details        = "-"
            };

            _context.Prescriptions_Medicaments.Add(prescription_medicament1);
            _context.Prescriptions_Medicaments.Add(prescription_medicament2);
        }