Ejemplo n.º 1
0
        public async Task <Patient> CreatePatient(PatientVM newPatientVM)
        {
            var dummyPatient = new Patient()
            {
                UserId  = UserId,
                Address = newPatientVM.Address,
                CivilRegistrationNumber        = newPatientVM.CivilRegistrationNumber,
                CivilStatusCode                = newPatientVM.CivilStatusCode,
                CountryIdentificationCode      = newPatientVM.CountryIdentificationCode,
                CountryIdentificationCodeSst   = newPatientVM.CountryIdentificationCodeSst,
                CountryIdentificationText      = newPatientVM.CountryIdentificationText,
                ParishDistrictCode             = newPatientVM.ParishDistrictCode,
                ParishDistrictText             = newPatientVM.ParishDistrictText,
                PersonGenderCode               = newPatientVM.PersonGenderCode,
                PopulationDistrictCode         = newPatientVM.PopulationDistrictCode,
                PopulationDistrictText         = newPatientVM.PopulationDistrictText,
                PractitionerIdentificationCode = newPatientVM.PractitionerIdentificationCode,
                RegionalCode       = newPatientVM.RegionalCode,
                RegionalName       = newPatientVM.RegionalName,
                SocialDistrictCode = newPatientVM.SocialDistrictCode,
                SocialDistrictText = newPatientVM.SocialDistrictText,
                StatusCode         = newPatientVM.StatusCode,
                PatientName        = newPatientVM.PatientName,
            };

            try
            {
                _context.Patients.Add(dummyPatient);
                await _context.SaveChangesAsync();

                return(dummyPatient);
            }
            catch (Exception ex)
            {
                await _logRepository.AddLog(UserId, ex.Message);

                return(null);
            }
        }
Ejemplo n.º 2
0
        public async void IntegrationTestDeleteProfile()
        {
            var options = new DbContextOptionsBuilder <BefordingTestContext>()
                          .UseInMemoryDatabase(databaseName: "BefordingTestDb")
                          .Options;
            var context = new BefordingTestContext(options);

            var logRepository = new LogRepository(context, _userInfoServiceMock.Object);

            var profileRepository = new ProfileRepository(context, _userInfoServiceMock.Object, logRepository);

            var dummyHospital = new HospitalProfile()
            {
                Address        = "Address",
                NameOfHospital = "UUU",
                Rate           = 0
            };

            context.Profiles.Add(dummyHospital);
            await context.SaveChangesAsync();

            Assert.True(context.Profiles.FirstOrDefaultAsync(x => x.Address == "Address") != null);
            Assert.True(context.Profiles.FirstOrDefaultAsync(x => x.Id == 1) != null);
            Assert.True(await context.Profiles.CountAsync() == 1);

            await profileRepository.DeleteProfileAdmin(1);

            Assert.True(await context.Profiles.CountAsync() == 0);

            Assert.True(await context.Logs.CountAsync() == 0);

            context.Profiles.Add(dummyHospital);
            await context.SaveChangesAsync();

            await profileRepository.DeleteProfileAdmin(-1);

            Assert.True(await context.Logs.CountAsync() == 1);
        }
Ejemplo n.º 3
0
        public async Task <HospitalProfile> CreateProfile(HospitalProfileVM newProfileVm)
        {
            var dummyProfile = new HospitalProfile()
            {
                UserId         = UserId,
                NameOfHospital = newProfileVm.NameOfHospital,
                Address        = newProfileVm.Address,
                Rate           = newProfileVm.Rate
            };

            try
            {
                _context.Profiles.Add(dummyProfile);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                await _logRepository.AddLog(UserId, ex.Message);

                return(null);
            }
            return(dummyProfile);
        }
Ejemplo n.º 4
0
 private async void fillMockDatabase(int numberOfElements, BefordingTestContext context)
 {
     for (int i = 0; i < numberOfElements; i++)
     {
         var dummyHospital = new HospitalProfile()
         {
             Address        = "" + i,
             NameOfHospital = "UUU",
             Rate           = i
         };
         context.Profiles.Add(dummyHospital);
         await context.SaveChangesAsync();
     }
 }
Ejemplo n.º 5
0
 private async Task StoreToDb(Log newLog)
 {
     _context.Logs.Add(newLog);
     await _context.SaveChangesAsync();
 }