示例#1
0
        public ModifyDoctorResponse ModifyDoctor(ModifyDoctorRequest request)
        {
            var response = new ModifyDoctorResponse();

            using (var doctorDbContext = new DoctorDbContext())
            {
                var entity = doctorDbContext.Doctors.FirstOrDefault(item => item.IdDoctor == request.doctor.IdDoctor);
                if (entity != null)
                {
                    entity.FirstName = request.doctor.FirstName;
                    entity.LastName  = request.doctor.LastName;
                    entity.Email     = request.doctor.Email;

                    try
                    {
                        doctorDbContext.SaveChanges();
                        response.message = "UPDATE SUCCESSFULL";
                    }
                    catch (Exception)
                    {
                        response.message = "UPDATE FAILED";
                    }
                }
                else
                {
                    response.message = "There is no doctor with this index!";
                }
            }
            return(response);
        }
示例#2
0
        public DeleteDoctorResponse DeleteDoctor(DeleteDoctorRequest request)
        {
            var response = new DeleteDoctorResponse();

            using (var doctorDbContext = new DoctorDbContext())
            {
                var doctorToDelete = doctorDbContext.Doctors.SingleOrDefault(doctor => doctor.IdDoctor.Equals(request.IdDoctor));
                if (doctorToDelete != null)
                {
                    try
                    {
                        doctorDbContext.Doctors.Remove(doctorToDelete);
                        doctorDbContext.SaveChanges();
                        response.message = "Doctor " + request.IdDoctor + " deleted successful";
                    }
                    catch (Exception)
                    {
                        response.message = "Doctor delete FAILED";
                    }
                }
                else
                {
                    response.message = "There is no such a doctor to delete!";
                }
            }
            return(response);
        }
示例#3
0
        public IActionResult DeleteDoctor(int id)
        {
            var db = new DoctorDbContext();

            var d1 = new Doctor()
            {
                IdDoctor = id
            };

            db.Attach(d1);
            db.Remove(d1);

            db.SaveChanges();

            return(Ok(d1));
        }
示例#4
0
        public IActionResult UpdateDoctor(DoctorRequest request)
        {
            var db = new DoctorDbContext();

            var d1 = new Doctor
            {
                IdDoctor  = request.IdDoctor,
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email
            };

            db.Attach(d1);
            db.SaveChanges();

            return(Ok(d1));
        }
示例#5
0
        public ShowDoctorDetailsResponse ShowDoctorDetails(ShowDoctorDetailsRequest request)
        {
            var             response        = new ShowDoctorDetailsResponse();
            DoctorDbContext doctorDbContext = new DoctorDbContext();

            var entity = doctorDbContext.Doctors.FirstOrDefault(item => item.IdDoctor == request.doctorId);

            if (entity != null)
            {
                response.message = entity.FirstName + " " + entity.LastName + " " + entity.Email;
            }
            else
            {
                response.message = "There is no such doctor with this id";
            }

            return(response);
        }
示例#6
0
        public AddDoctorResponse AddDoctor(AddDoctorRequest request)
        {
            var response = new AddDoctorResponse();

            using (var doctorContext = new DoctorDbContext())
            {
                doctorContext.Doctors.Add(request.doctor);
                try
                {
                    doctorContext.SaveChanges();
                    response.message = "INSERT SUCCESSFUL";
                }
                catch (Exception)
                {
                    response.message = "INSERT FAILED";
                }
            }
            return(response);
        }
 public DbServiceImpl(DoctorDbContext doctorDbContext)
 {
     this.context = doctorDbContext;
 }
示例#8
0
 public DoctorController(DoctorDbContext context)
 {
     _context = context;
 }
示例#9
0
 public EFDbService(DoctorDbContext db)
 {
     _db = db;
 }
示例#10
0
 public DbService(DoctorDbContext doctorDbContext)
 {
     this.doctorDbContext = doctorDbContext;
 }
示例#11
0
 public DoctorsService(DoctorDbContext context)
 {
     _context = context;
 }
示例#12
0
        public MsSqlService(DoctorDbContext doctorDbContext)
        {
            _doctorDbContext = doctorDbContext;
            _doctorDbContext.Doctors.Add(new Doctor()
            {
                FirstName = "Johnny",
                LastName  = "Sins",
                Email     = "*****@*****.**"
            });
            _doctorDbContext.Doctors.Add(new Doctor()
            {
                FirstName = "Jack",
                LastName  = "Sparrow",
                Email     = "*****@*****.**"
            });
            _doctorDbContext.Medicaments.Add(new Medicament()
            {
                Name        = "Apap",
                Description = "Headache",
                Type        = "Painkiller"
            });
            _doctorDbContext.Medicaments.Add(new Medicament()
            {
                Name        = "Ibuprom",
                Description = "Headache",
                Type        = "Painkiller"
            });
            _doctorDbContext.Patients.Add(new Patient()
            {
                FirstName = "Jacob",
                LastName  = "Smith",
                BirthDate = DateTime.Parse("2000-10-10")
            });
            _doctorDbContext.Patients.Add(new Patient()
            {
                FirstName = "Ahmad",
                LastName  = "Opx",
                BirthDate = DateTime.Parse("2010-02-11")
            });
            _doctorDbContext.Prescriptions.Add(new Prescription()
            {
                Date      = DateTime.Parse("2000-10-10"),
                DueDate   = DateTime.Today,
                IdDoctor  = 1,
                IdPatient = 1
            });
            _doctorDbContext.Prescriptions.Add(new Prescription()
            {
                Date      = DateTime.Parse("2010-10-10"),
                DueDate   = DateTime.Today,
                IdDoctor  = 2,
                IdPatient = 2
            });
            _doctorDbContext.PrescriptionMedicament.Add(new PrescriptionMedicament()
            {
                IdMedicament   = 1,
                IdPrescription = 1,
                Details        = "2 times a day",
                Dose           = 1
            });
            _doctorDbContext.PrescriptionMedicament.Add(new PrescriptionMedicament()
            {
                IdMedicament   = 2,
                IdPrescription = 2,
                Details        = "3 times a day",
                Dose           = 3
            });

            _doctorDbContext.SaveChanges();
        }
示例#13
0
 public efDbService(DoctorDbContext dbContext)
 {
     _dbService = dbContext;
 }
示例#14
0
 public UnitOfWork(DoctorDbContext context, IHttpContextAccessor contextAccessor)
 {
     Context          = context;
     _contextAccessor = contextAccessor;
 }
示例#15
0
 public DbService(DoctorDbContext dbContext)
 {
     _dbContext = dbContext;
 }
示例#16
0
 public EfDoctorDbService(DoctorDbContext context)
 {
     _context = context;
 }
示例#17
0
 public SqlServerDoctorDbService(DoctorDbContext context)
 {
     _context = context;
 }
 public DoctorServiceImpl(DoctorDbContext context)
 {
     _context = context;
 }
示例#19
0
 public BaseService()
 {
     _dbContext  = new DoctorDbContext();
     _innerDbSet = _dbContext.Set <T>();
 }