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); }
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); }
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)); }
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)); }
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); }
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; }
public DoctorController(DoctorDbContext context) { _context = context; }
public EFDbService(DoctorDbContext db) { _db = db; }
public DbService(DoctorDbContext doctorDbContext) { this.doctorDbContext = doctorDbContext; }
public DoctorsService(DoctorDbContext context) { _context = context; }
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(); }
public efDbService(DoctorDbContext dbContext) { _dbService = dbContext; }
public UnitOfWork(DoctorDbContext context, IHttpContextAccessor contextAccessor) { Context = context; _contextAccessor = contextAccessor; }
public DbService(DoctorDbContext dbContext) { _dbContext = dbContext; }
public EfDoctorDbService(DoctorDbContext context) { _context = context; }
public SqlServerDoctorDbService(DoctorDbContext context) { _context = context; }
public DoctorServiceImpl(DoctorDbContext context) { _context = context; }
public BaseService() { _dbContext = new DoctorDbContext(); _innerDbSet = _dbContext.Set <T>(); }