public void DeleteShouldTrhowException(string id, bool isDeleted) { //// Arrange var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(DeleteShouldTrhowException)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var doctor = new Doctor { Id = Guid.NewGuid().ToString(), FirstName = "TestDoctor", MiddleName = "TestDoctors", ThirdName = "FamilyName", IsDeleted = isDeleted, }; context.Doctors.Add(doctor); context.SaveChangesAsync().GetAwaiter().GetResult(); //// Assert Assert.That( () => service.Delete(id).GetAwaiter().GetResult(), Throws.TypeOf <ArgumentException>().With.Message.EqualTo("Doctor does not exist.")); Assert.That( () => service.Delete(doctor.Id).GetAwaiter().GetResult(), Throws.TypeOf <ArgumentException>().With.Message.EqualTo("Doctor does not exist.")); }
public void DeleteDoctorShouldWorkProperly() { //// Arrange var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(DeleteShouldTrhowException)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var doctor = new Doctor { Id = Guid.NewGuid().ToString(), FirstName = "TestDoctor", MiddleName = "TestDoctors", ThirdName = "FamilyName", IsDeleted = false, }; context.Doctors.Add(doctor); context.SaveChangesAsync().GetAwaiter().GetResult(); //// Act service.Delete(doctor.Id).GetAwaiter().GetResult(); //// Assert var doctorModel = context.Doctors.FirstOrDefault(x => x.Id == doctor.Id); Assert.AreEqual(true, doctorModel.IsDeleted); }
public void GetAllShouldReturnICollection() { //// Arange AutoMapperConfig.RegisterMappings( typeof(DoctorViewModel).GetTypeInfo().Assembly); var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(GetAllShouldReturnICollection)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var inputDoctors = new List <Doctor>() { new Doctor { FirstName = "Ivan", ThirdName = "Zlatev" }, new Doctor { FirstName = "Peshi", ThirdName = "Georgiev" }, }; context.Doctors.AddRange(inputDoctors); context.SaveChanges(); //// Act var resultDoctors = service.GetAll <DoctorViewModel>().GetAwaiter().GetResult(); //// Assert Assert.AreEqual(true, resultDoctors is ICollection <DoctorViewModel>); }
public DoctorsController(DoctorsService doctorsService, PatientService patientService, Broadcaster broadcaster) { this.doctorsService = doctorsService; this.patientService = patientService; this.broadcaster = broadcaster; }
public void GetByIdShouldThrowErrorWhenEntityIsDeleted() { AutoMapperConfig.RegisterMappings( typeof(DoctorViewModel).GetTypeInfo().Assembly); var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(GetByIdShouldThrowErrorWhenEntityIsDeleted)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var doctor = new Doctor { Id = Guid.NewGuid().ToString(), IsDeleted = true, }; context.Doctors.AddAsync(doctor); context.SaveChangesAsync(); Assert.That( () => service.GetById <DoctorViewModel>(doctor.Id).GetAwaiter().GetResult(), Throws.TypeOf <ArgumentException>().With.Message.EqualTo("Doctor does not exist.")); }
public EmployeeController(EmployeeService employeeService, DoctorsService doctorService, DonorService donorService, IEmailSender _emailSender, Broadcaster broadcaster) { this.employeeService = employeeService; this.doctorService = doctorService; this.broadcaster = broadcaster; this._emailSender = _emailSender; this.donorService = donorService; }
public DoctorsController(DoctorsRepository doctorsRepository, DoctorsService doctorsService, IMapper mapper, PaginatedMetaService paginatedMetaService, FileHelper fileHelper) { _doctorsRepository = doctorsRepository; _doctorsService = doctorsService; _mapper = mapper; _paginatedMetaService = paginatedMetaService; _fileHelper = fileHelper; }
public override async Task InitAsync() { await ExecuteAsync(async() => { Patient = await PatientsService.GetByIdAsync(id); Doctors = new ObservableCollection <Doctor>(await DoctorsService.GetAllAsync()); DoctorSelected = Patient.Doctor; }); }
public void EditDoctorShouldChangeSpecility() { //// Arange var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(EditDoctorShouldChangeSpecility)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var doctor = new Doctor { Id = Guid.NewGuid().ToString(), FirstName = "John", MiddleName = "Doe", ThirdName = "Johnson", IsDeleted = false, Speciality = new Speciality { Id = 1, Name = "Doctor" } }; var editSpeciality = new Speciality { Id = 2, Name = "Pediatritian", }; context.Specialities.Add(editSpeciality); context.Doctors.Add(doctor); context.SaveChanges(); //// Act var editDoctor = new Doctor { Id = doctor.Id, FirstName = doctor.FirstName, MiddleName = doctor.MiddleName, ThirdName = doctor.ThirdName, IsDeleted = false, Speciality = editSpeciality, }; service.EditDoctorInfo(editDoctor).GetAwaiter().GetResult(); var resultDoctor = context.Doctors.SingleOrDefault(x => x.Id == editDoctor.Id && x.IsDeleted == false); Assert.AreEqual(editSpeciality.Id, resultDoctor.Speciality.Id); Assert.AreEqual(editSpeciality.Name, resultDoctor.Speciality.Name); }
public void GetByIdShouldReturnInputModelProperly( string firstName, string middleName, string lastName, string email, string description, int speciality, string specailityName, string phone) { //// Arange AutoMapperConfig.RegisterMappings( typeof(DoctorViewModel).GetTypeInfo().Assembly); var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(GetByIdShouldReturnInputModelProperly)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var specialityModel = new Speciality { Id = speciality, Name = specailityName }; var doctor = new Doctor { Id = Guid.NewGuid().ToString(), FirstName = firstName, MiddleName = middleName, ThirdName = lastName, Email = email, Description = description, Speciality = specialityModel, PhoneNumber = phone, }; context.Doctors.Add(doctor); context.Specialities.Add(specialityModel); context.SaveChanges(); //// Act var resultDoctor = service.GetById <DoctorInputModel>(doctor.Id).GetAwaiter().GetResult(); //// Assert Assert.AreEqual(doctor.FirstName, resultDoctor.FirstName); Assert.AreEqual(doctor.MiddleName, resultDoctor.MiddleName); Assert.AreEqual(doctor.ThirdName, resultDoctor.ThirdName); Assert.AreEqual(doctor.Email, resultDoctor.Email); Assert.AreEqual(doctor.Description, resultDoctor.Description); Assert.AreEqual(doctor.Speciality.Id, resultDoctor.SpecialityId); Assert.AreEqual(doctor.PhoneNumber, resultDoctor.PhoneNumber); Assert.AreEqual(doctor.Id, resultDoctor.Id); Assert.AreEqual(typeof(DoctorInputModel), resultDoctor.GetType()); }
public void EditDoctorShouldThrowException(string id, bool isDeleted) { //// Arange var options = new DbContextOptionsBuilder() .UseInMemoryDatabase(nameof(EditDoctorShouldThrowException)) .Options; var context = new S2DentDbContext(options); var service = new DoctorsService(context); var doctor = new Doctor { Id = Guid.NewGuid().ToString(), FirstName = "SomeFirstName", MiddleName = "SomeMiddleName", IsDeleted = isDeleted, }; context.Doctors.Add(doctor); context.SaveChangesAsync().GetAwaiter().GetResult(); //// Act var testInputDoctor = new Doctor { Id = id, FirstName = doctor.FirstName, MiddleName = doctor.MiddleName, IsDeleted = false }; var secondTestInputDoctor = new Doctor { Id = doctor.Id, FirstName = doctor.FirstName, MiddleName = doctor.MiddleName, IsDeleted = doctor.IsDeleted, }; //// Assert Assert.That( () => service.EditDoctorInfo(testInputDoctor).GetAwaiter().GetResult(), Throws.TypeOf <ArgumentException>().With.Message.EqualTo("Doctor does not exist.")); Assert.That( () => service.EditDoctorInfo(secondTestInputDoctor).GetAwaiter().GetResult(), Throws.TypeOf <ArgumentException>().With.Message.EqualTo("Doctor does not exist.")); }
public void EditDoctorShowldChangeBasicProperties( string id, string firstName, string middleName, string lastName) { //// Arange var options = new DbContextOptionsBuilder <S2DentDbContext>() .UseInMemoryDatabase(nameof(EditDoctorShowldChangeBasicProperties)) .Options; using var context = new S2DentDbContext(options); var service = new DoctorsService(context); var doctor = new Doctor { Id = id, FirstName = "John", MiddleName = "Doe", ThirdName = "Johnson", IsDeleted = false, }; context.Doctors.Add(doctor); context.SaveChanges(); //// Act var editDoctor = new Doctor { Id = id, FirstName = firstName, MiddleName = middleName, ThirdName = lastName, }; service.EditDoctorInfo(editDoctor).GetAwaiter().GetResult(); //// Asert var doctorModel = context.Doctors.AsNoTracking().FirstOrDefault(x => x.Id == doctor.Id); Assert.AreEqual(editDoctor.Id, doctorModel.Id); Assert.AreEqual(editDoctor.FirstName, doctorModel.FirstName); Assert.AreEqual(editDoctor.MiddleName, doctorModel.MiddleName); Assert.AreEqual(editDoctor.ThirdName, doctorModel.ThirdName); }
public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IEmailSender emailSender, ILogger <AccountController> logger, DoctorsService doctorsService, DonorService donorService, AdminService adminService, EmployeeService employeeService, Broadcaster broadcaster) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = logger; _doctorsService = doctorsService; _adminService = adminService; _donorsService = donorService; _employeeService = employeeService; _broadcaster = broadcaster; }
public static void Main(string[] args) { using (HealthDbContext db = new HealthDbContext()) { //db.Database.EnsureDeleted(); //db.Database.EnsureCreated(); db.Database.Migrate(); //Seed seed = new Seed(); //seed.SeedDataBase(db); IBloodsService bloodsService = new BloodsService(db); IAddressesService addressesService = new AddressesService(db); IPhonesService phonesService = new PhonesService(db); IEmailsService emailsService = new EmailsService(db); IRelativesService relativesService = new RelativesService(db, addressesService, phonesService, emailsService); IDoctorsService doctorsService = new DoctorsService(db, addressesService, phonesService, emailsService); IPersonsService personsService = new PersonsService(db, addressesService, phonesService, emailsService, relativesService); IVaccinesService vaccinesService = new VaccinesService(db); IAllergiesService allergiesService = new AllergiesService(db); IChronicDiseasesService chronicDiseasesService = new ChronicDiseasesService(db); IPersonDiseasesService personVaccinesService = new PersonVaccinesService(db, vaccinesService); IPersonDiseasesService personAlleriesService = new PersonAllergiesService(db, allergiesService); IPersonDiseasesService personChronicDiseasesService = new PersonChronicDiseasesService(db, chronicDiseasesService); IMedicinesService medicinesService = new MedicinesService(db); IPrescriptionsService prescriptionsService = new PrescriptionsService(db, medicinesService); IReferralsService referralsService = new ReferralsService(db); ITreatmentsService treatmentsService = new TreatmentsService(db); IExaminationsService examinationsService = new ExaminationsService(db); IHospitalizationsService hospitalizationsService = new HospitalizationsService(db, examinationsService, treatmentsService); #region //examinationsService.Add(new ExaminationInputModel() //{ // Date = "21.09.2019", // Diagnosis = "very sick man", // DoctorId = "bedfa8a0-46d7-4369-8f85-fe3b1be57095", // PersonId = "9c591451-96e6-4dff-a225-32f092c7b56d", //}); //prescriptionsService.Add("565d1e5a-68df-45ab-8fea-e9d914fc891f"); //prescriptionsService.AddMedicine("7db87d46-6d71-4355-a482-95e2bf726465", // new MedicineInputModel() // { // Name = "Mesalazin Unipharm", // DaylyDoze = "250mg" // }); //examinationsService.AddPrescription("565d1e5a-68df-45ab-8fea-e9d914fc891f", "7db87d46-6d71-4355-a482-95e2bf726465"); //string referralId = referralsService.Add(new ReferralInputModel() // { // ExaminationId = "565d1e5a-68df-45ab-8fea-e9d914fc891f", // Specialty = "Cardiologist" // }); //examinationsService.AddReferral("565d1e5a-68df-45ab-8fea-e9d914fc891f", referralId); //hospitalizationsService.AddExamination("22a65132-1949-4e13-bbbc-35201429d0fb", "565d1e5a-68df-45ab-8fea-e9d914fc891f"); //hospitalizationsService.AddTreatment("22a65132-1949-4e13-bbbc-35201429d0fb", "44f6112f-542a-4eaf-a0b9-5685441f3937"); //hospitalizationsService.Add(new HospitalizationInputModel() //{ // EnterDate = "20.08.2019", // DischargeDate = "25.08.2019", // HospitalId = 1, // PersonId = "9c591451-96e6-4dff-a225-32f092c7b56d" //}); //hospitalizationsService.Add(new HospitalizationInputModel() //{ // EnterDate = "20.09.2019", // HospitalId = 1, // PersonId = "9c591451-96e6-4dff-a225-32f092c7b56d" //}); //treatmentsService.Add(new TreatmentInputModel() //{ // Description = "knee surgery...", // Date = "21.09.2019", // DoctorId = "bedfa8a0-46d7-4369-8f85-fe3b1be57095", // HospitalizationId = "22a65132-1949-4e13-bbbc-35201429d0fb" //}); //doctorsService.Add(new DoctorInputModel() //{ // FirstName = "Boiko", // LastName = "Penkov", // HospitalId = 1, // Specialty = "Cardiologist", // Address = new AddressInputModel() // { // Town = "Sofia", // Street = "ul. Alen Mak 1" // }, // Phone = new PhoneInputModel() // { // PhoneNumber = "0888989898" // }, // Email = new EmailAddressInputModel() // { // Email = "*****@*****.**" // }, //}); //personChronicDiseasesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095", // "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel() // { // Name = "Parkinson disease", // DiagnosedOn = "13.10.1973" // }); //personChronicDiseasesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095", // "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel() // { // Name = "Parkinson disease new", // DiagnosedOn = "13.10.1973" // }); //personAlleriesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095", // "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel() // { // Name = "Wheat[26]", // DiagnosedOn = "13.10.1973" // }); //personAlleriesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095", // "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel() // { // Name = "Wheat[26] (1)", // DiagnosedOn = "13.10.1973" // }); //personVaccinesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095", // "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel() // { // Name = "Strontium chloride", // DiagnosedOn = "13.10.1973" // }); //personVaccinesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095", // "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel() // { // Name = "Strontium chloride new", // DiagnosedOn = "13.10.1973" // }); //PersonInputModel personInputModel = new PersonInputModel() //{ // FirstName = "Kamen", // MiddleName = "Dimitrov", // LastName = "Pankov", // PersonalNumber = "7310136488", // BloodId = bloodsService.GetBloodId(BloodType.A, RhD.Negative), // HasHealthInsurance = true, // Address = new AddressInputModel() // { // Town = "Sofia", // Street = "Lerin 45" // } //}; //personsService.Add(personInputModel); //Person person = personsService.GetPerson("9c591451-96e6-4dff-a225-32f092c7b56d"); //personsService.AddPhone("9c591451-96e6-4dff-a225-32f092c7b56d", new PhoneInputModel() //{ // PhoneNumber = "0888086820" //}); //personsService.AddEmail("9c591451-96e6-4dff-a225-32f092c7b56d", new EmailAddressInputModel() //{ // Email = "*****@*****.**" //}); //personsService.AddRelative("9c591451-96e6-4dff-a225-32f092c7b56d", // new RelativeInputModel() // { // FirstName = "Desi", // MiddleName = "Svetlozarova", // LastName = "Velkovska", // Address = new AddressInputModel() // { // Town = "Sofia", // Street = "ul. Dobrudjanski krai 1" // }, // Phone = new PhoneInputModel() // { // PhoneNumber = "0888127876" // }, // Email = new EmailAddressInputModel() // { // Email = "*****@*****.**" // }, // RelativeType = "spouse" // }); #endregion } }