示例#1
0
        public void Given_AppointmentRepository_When_EditingAnAppointment_Then_TheAppointmentShouldBeProperlyEdited()
        {
            RunOnDatabase(async ctx =>
            {
                //Arrange
                var repository = new AppointmentRepository(ctx);
                var patient    = Patient.Create("1234", "Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null);
                var patient2   = Patient.Create("1234", "Roland", "Iordache2", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null);
                var doctor     = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);

                var appointmentInterval = AppointmentInterval.Create(3, new TimeSpan(0, 10, 0, 0), new TimeSpan(0, 11, 0, 0), doctor.DoctorId);
                var appointment         = Appointment.Create(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient.PatientId);



                await repository.AddAsync(appointment);

                var appointmentPatient = appointment.Patient;
                appointment.Update(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient2.PatientId, appointment.HaveFeedback, appointment.HaveMedicalHistory);

                //Act
                await repository.UpdateAsync(appointment);

                //Assert
                Assert.AreNotEqual(appointmentPatient, appointment.Patient);
            });
        }
示例#2
0
        public void Given_AppointmentRepository_When_DeletingAnAppointment_Then_TheAppointmentShouldBeProperlyRemoved()
        {
            RunOnDatabase(async ctx =>
            {
                //Arrange
                var repository          = new AppointmentRepository(ctx);
                var patient             = Patient.Create("1234", "Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null);
                var doctor              = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);
                var appointmentInterval = AppointmentInterval.Create(3, new TimeSpan(0, 10, 0, 0), new TimeSpan(0, 11, 0, 0), doctor.DoctorId);
                var appointment         = Appointment.Create(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient.PatientId);
                await repository.AddAsync(appointment);

                //Act
                await repository.DeleteAsync(appointment.PatientId);

                //Assert
                string[] includes = { };
                Assert.AreEqual(repository.GetAllAsync(includes).Result.Count, 0);
            });
        }
示例#3
0
        public async Task <ActionResult> CreateAppointmentInterval([FromBody] AppointmentIntervalModel appointmentInterval, [FromHeader(Name = "Authorization")] string value)
        {
            var token    = new JwtSecurityTokenHandler().ReadJwtToken(value);
            var issuer   = token.Claims.First(claim => claim.Type == "iss").Value;
            var audience = token.Claims.First(claim => claim.Type == "aud").Value;

            if (issuer != "MyIssuer" || audience != "MyAudience")
            {
                return(Unauthorized());
            }


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var instance = AppointmentInterval.Create(appointmentInterval.Day, appointmentInterval.StartHour, appointmentInterval.EndHour, appointmentInterval.DoctorId);

            try
            {
                var newAppointmentInterval = await _repository.AddAsync(instance);

                if (newAppointmentInterval == null)
                {
                    return(BadRequest(new ApiResponse {
                        Status = false
                    }));
                }
                return(CreatedAtRoute("GetAppointmentIntervalRoute", new { id = newAppointmentInterval.AppointmentIntervalId },
                                      new ApiResponse {
                    Status = true, AppointmentInterval = newAppointmentInterval
                }));
            }
            catch
            {
                return(BadRequest(new ApiResponse {
                    Status = false
                }));
            }
        }