Example #1
0
        public IActionResult ModifyDoctor(int id, DoctorUp doctor)
        {
            var d = new Doctor
            {
                IdDoctor     = id,
                FirstName    = doctor.FirstName,
                LastName     = doctor.LastName,
                Email        = doctor.Email,
                Prescription = doctor.Prescription
            };

            try{
                //  db.Attach(d);
                // db.Entry(d).Property("LastName").IsModified=true;
                db.Update(d);
                db.SaveChanges();
            }catch (Exception e) {
                return(NotFound("Dla: " + id + ", wystapil blad:\n" + e));
            }
            return(Ok("Updated: " + id));
        }
Example #2
0
 public bool UpdateDoctor(Doctor doctor)
 {
     _dbService.Update(doctor);
     try
     {
         _dbService.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #3
0
        public Doctor UpdateDoc(UpdateDoctor request)
        {
            var d = context.Doctor.FirstOrDefault(a => a.IdDoctor == request.IdDoctor);

            if (d != null)
            {
                d.FirstName = request.FirstName;
                d.LastName  = request.LastName;
                d.Email     = request.Email;

                context.Update(d);
                context.SaveChanges();

                return(d);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public Doctor UpdateDoctor(UpdateDoctorRequest request)
        {
            var d = _db.Doctor.Where(e => e.IdDoctor == request.IdDoctor).FirstOrDefault();

            if (d != null)
            {
                d.FirstName = request.FirstName;
                d.LastName  = request.LastName;
                d.Email     = request.Email;

                _db.Update(d);
                _db.SaveChanges();

                return(d);
            }
            else
            {
                return(null);
            }
        }
Example #5
0
 public void MidifyDoctor(Doctor doctor)
 {
     _db.Update(doctor);
     _db.SaveChanges();
 }
Example #6
0
        public IActionResult Seed()
        {
            try
            {
                var doctor1 = new Doctor();
                doctor1.FirstName     = "Oleksandr";
                doctor1.LastName      = "Malaniuk";
                doctor1.Email         = "email123.gm.com";
                doctor1.Prescriptions = new List <Prescription>();
                _cfContext.Doctor.Add(doctor1);

                Console.WriteLine(doctor1.ToString());
                var patient1 = new Patient();
                patient1.FirstName     = "Oleg";
                patient1.LastName      = "Little";
                patient1.BirthDate     = DateTime.Now.AddYears(-30);
                patient1.Prescriptions = new List <Prescription>();

                _cfContext.Patient.Add(patient1);

                var medicament1 = new Medicament();
                medicament1.Description             = "Przeciw kataru";
                medicament1.Name                    = "KatarKill";
                medicament1.Type                    = "Sprej";
                medicament1.PrescriptionsMedicament = new List <PrescriptionMedicament>();

                _cfContext.Medicament.Add(medicament1);



                var prescription1 = new Prescription();
                prescription1.Date      = DateTime.Now;
                prescription1.DueDate   = DateTime.Now.AddDays(10);
                prescription1.IdPatient = patient1.IdPatient;
                prescription1.IdDoctor  = doctor1.IdDoctor;

                prescription1.Doctor  = doctor1;
                prescription1.Patient = patient1;

                prescription1.PrescriptionsMedicament = new List <PrescriptionMedicament>();

                _cfContext.Prescription.Add(prescription1);
                _cfContext.SaveChanges();
                doctor1.Prescriptions.Add(prescription1);
                patient1.Prescriptions.Add(prescription1);

                _cfContext.Update(doctor1);
                _cfContext.Update(patient1);
                _cfContext.SaveChanges();

                var prescriptionMedicament1 = new PrescriptionMedicament();
                prescriptionMedicament1.IdMedicament = _cfContext.Medicament.Where(e => e.Name == medicament1.Name &&
                                                                                   e.Description == medicament1.Description && e.Type == medicament1.Type).First().IdMedicament;

                prescriptionMedicament1.IdPrescription = _cfContext.Prescription.Where(e => e.IdDoctor == prescription1.IdDoctor &&
                                                                                       e.IdPatient == prescription1.IdPatient).First().IdPrescription;

                prescriptionMedicament1.Dose       = 1;
                prescriptionMedicament1.Details    = "Codzienie 1 raz wieczorem";
                prescriptionMedicament1.Medicament = medicament1;

                prescriptionMedicament1.Prescription = prescription1;


                _cfContext.PrescriptionMedicaments.Add(prescriptionMedicament1);
                _cfContext.SaveChanges();
                prescription1.PrescriptionsMedicament.Add(prescriptionMedicament1);
                medicament1.PrescriptionsMedicament.Add(prescriptionMedicament1);

                _cfContext.Update(prescription1);
                _cfContext.Update(medicament1);
                _cfContext.SaveChanges();
            }
            catch (Exception e)
            {
                return(NotFound("Something went wrong" + e));
            }
            return(Ok("Ok"));
        }