public PatientValidator(CepresDBContext context)
 {
     _patients = context.Patients;
     RuleFor(x => x.PatientName).NotEmpty();
     RuleFor(x => x.OfficialID).NotEmpty().Must(IsNameUnique).WithMessage("Patient with this OfficialID is exists.");
     RuleFor(x => x.EmailAddress).EmailAddress();
 }
        public static void Initialize(CepresDBContext context)
        {
            if (context.Patients.Any())
            {
                return;
            }

            Seed(context);
        }
Exemple #3
0
        public CepresDBContextTest()
        {
            var options = new DbContextOptionsBuilder <CepresDBContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            _context = new CepresDBContext(options);

            _context.Database.EnsureCreated();

            CepresDBContextInitializer.Initialize(_context);
        }
        private static void Seed(CepresDBContext context)
        {
            var Patients = new[]
            {
                new PatientModel {
                    PatientId    = Guid.Parse("6ee3bcef-fafb-41c4-a400-464f3a91973e"),
                    PatientName  = "Mohamamd Modrek",
                    EmailAddress = "*****@*****.**",
                    OfficialID   = 1286015928,
                    DateOfBirth  = DateTime.Now,
                    MetaData     = new List <MetaDataModel> {
                        new MetaDataModel {
                            Key = "Diabet", Value = "No"
                        },
                        new MetaDataModel {
                            Key = "Blood", Value = "O+"
                        }
                    }
                },
                new PatientModel {
                    PatientId    = Guid.Parse("7d950fc9-b874-41cb-85af-c2f99dd47343"),
                    PatientName  = "Ali Modrek",
                    EmailAddress = "*****@*****.**",
                    OfficialID   = 1286015929,
                    DateOfBirth  = DateTime.Now,
                    MetaData     = new List <MetaDataModel> {
                        new MetaDataModel {
                            Key = "Diabet", Value = "Yes"
                        },
                        new MetaDataModel {
                            Key = "Blood", Value = "B-"
                        }
                    }
                },
            };

            context.Patients.AddRange(Patients);
            RecordModel record = new RecordModel()
            {
                PatientId   = Guid.Parse("7d950fc9-b874-41cb-85af-c2f99dd47343"),
                Bill        = 15 / 57,
                Description = "No desc",
                DiseaseName = "Diabet",
                TimeOfEntry = DateTime.Now
            };

            context.Records.Add(record);
            context.SaveChanges();
        }
Exemple #5
0
 public Repository(CepresDBContext context)
 {
     _context = context;
 }
 public RecordRepository(CepresDBContext context) : base(context)
 {
     _context = context;
 }
Exemple #7
0
 public PatientRepository(CepresDBContext context) : base(context)
 {
     _context = context;
 }