Exemplo n.º 1
0
            public async Task <CreateCitizenResult> Handle(CreateCitizenCommand request, CancellationToken cancellationToken)
            {
                await request.Photo.SaveAsync(_directories.CitizenPhotosDirectory);

                var citizen = new CitizenDetail
                {
                    PrivateKey   = await _cryptographyService.EncryptAsync(_keys.PrivateKeyXml),
                    PublicKey    = _keys.PublicKeyXml,
                    Id           = Guid.NewGuid().ToString(),
                    FatherId     = request.FatherId,
                    MotherId     = request.MotherId,
                    FullName     = request.FullName,
                    Address      = request.Address,
                    Gender       = request.Gender,
                    Religion     = request.Religion,
                    SocialStatus = request.SocialStatus,
                    DateOfBirth  = request.DateOfBirth,
                    PhotoUrl     = request.Photo.Name,
                    HealthInfo   = new HealthInfo
                    {
                        Phone1    = request.HealthEmergencyPhone1,
                        Phone2    = request.HealthEmergencyPhone2,
                        Phone3    = request.HealthEmergencyPhone3,
                        BloodType = request.BloodType
                    }
                };

                await _context.CitizenDetails.AddAsync(citizen, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                return(new CreateCitizenResult {
                    CitizenId = citizen.Id, HealthInfoId = citizen.HealthInfo.Id
                });
            }
Exemplo n.º 2
0
            private async Task InitializeAdmin()
            {
                if (await _cardManager.AnyAsync)
                {
                    return;
                }

                var adminCitizen = new CitizenDetail
                {
                    Id           = _config["Admin:citizenId"],
                    FullName     = new FullName("محمود", "حمدي", "شعبان", "شاهين"),
                    Address      = new Address("Street", "City", "State", "Country", "12345"),
                    PhotoUrl     = "admin.png",
                    Create       = DateTime.Now,
                    PrivateKey   = await _cryptographyService.EncryptAsync(_citizenKeys.PrivateKeyXml),
                    PublicKey    = _citizenKeys.PublicKeyXml,
                    Religion     = Religion.Muslim,
                    Gender       = Gender.Male,
                    SocialStatus = SocialStatus.Single,
                    HealthInfo   = new HealthInfo
                    {
                        Id        = Guid.NewGuid().ToString(),
                        BloodType = BloodType.A,
                        Phone1    = "+20101234567"
                    }
                };

                await _context.CitizenDetails.AddAsync(adminCitizen);

                await _context.SaveChangesAsync();

                var(result, cardId) = await _cardManager.RegisterAdminAsync(
                    _config["Admin:cardId"],
                    adminCitizen.Id,
                    "#m1234567",
                    "*****@*****.**",
                    "010000000000000"
                    );

                if (!result.Succeeded)
                {
                    throw new Exception("failed to initialize admin");
                }

                result = await _cardManager.AddToRoleAsync(cardId, Roles.Admin);

                if (!result.Succeeded)
                {
                    throw new Exception("failed to add admin to the admin role");
                }
            }
Exemplo n.º 3
0
            private async Task SeedData1()
            {
                var id1     = Guid.NewGuid().ToString();
                var health1 = Guid.NewGuid().ToString();

                var citizen1 = new CitizenDetail
                {
                    Id           = id1,
                    FullName     = new FullName("محمود", "محمود", "حمدي", "شاهين"),
                    Address      = new Address(),
                    Gender       = Gender.Male,
                    Religion     = Religion.Muslim,
                    SocialStatus = SocialStatus.Married,
                    DateOfBirth  = DateTime.Now,
                    PrivateKey   = await _cryptographyService.EncryptAsync(_citizenKeys.PrivateKeyXml),
                    PublicKey    = _citizenKeys.PublicKeyXml,
                    PhotoUrl     = "test.jfif",
                    HealthInfo   = new HealthInfo()
                    {
                        Id        = health1,
                        BloodType = BloodType.None,
                        Phone1    = "010123123456",
                        Phone2    = "010133123456",
                        Phone3    = "010113123456",
                    },
                };

                await _context.CitizenDetails.AddAsync(citizen1);

                await _context.SaveChangesAsync();

                await _cardManager.RegisterAsync(new CreateCardCommand
                {
                    Puk     = "#m123456",
                    Pin1    = "#m123456",
                    Pin2    = "#m123456",
                    OwnerId = id1
                });
            }
Exemplo n.º 4
0
            private async Task SeedData()
            {
                var id1     = Guid.NewGuid().ToString();
                var health1 = Guid.NewGuid().ToString();

                var citizen1 = new CitizenDetail
                {
                    Id           = id1,
                    FullName     = new FullName("محمد", "محمود", "حسين", "سلامة"),
                    Address      = new Address(),
                    Gender       = Gender.Male,
                    Religion     = Religion.Muslim,
                    SocialStatus = SocialStatus.Married,
                    DateOfBirth  = DateTime.Now,
                    PrivateKey   = await _cryptographyService.EncryptAsync(_citizenKeys.PrivateKeyXml),
                    PublicKey    = _citizenKeys.PublicKeyXml,
                    PhotoUrl     = "test.jfif",
                    HealthInfo   = new HealthInfo()
                    {
                        Id        = health1,
                        BloodType = BloodType.None,
                        Phone1    = "010123123456",
                        Phone2    = "010133123456",
                        Phone3    = "010113123456",
                    },
                    Create   = DateTime.Now,
                    CreateBy = "lorem ipsum",
                };

                await _context.CitizenDetails.AddAsync(citizen1);

                await _context.SaveChangesAsync();

                await _cardManager.RegisterAsync(new CreateCardCommand
                {
                    Puk     = "#m123456",
                    Pin1    = "#m123456",
                    Pin2    = "#m123456",
                    OwnerId = id1
                });


                citizen1.HealthInfo.HealthRecords.Add(
                    new HealthRecord
                {
                    Id          = Guid.NewGuid().ToString(),
                    Diagnosis   = "كسر في عظام الساق نتيجة حادث موتوسيكل",
                    Medications = "الادوية مرفقة مرفعة كصورة من الروشته",
                    Attachments = new List <HealthRecordAttachment>
                    {
                        new HealthRecordAttachment
                        {
                            Id = "radiology.jpg"
                        },
                        new HealthRecordAttachment
                        {
                            Id = "roshta.jpg"
                        }
                    }
                }
                    );

                citizen1.HealthInfo.HealthRecords.Add(
                    new HealthRecord
                {
                    Id           = Guid.NewGuid().ToString(),
                    HealthInfoId = health1,
                    Diagnosis    = "كسر في عظام الساق نتيجة حادث موتوسيكل",
                    Medications  = "الادوية مرفقة مرفعة كصورة من الروشته",
                    Attachments  = new List <HealthRecordAttachment>
                    {
                        new HealthRecordAttachment
                        {
                            Id = "radiology - Copy (2).jpg"
                        },
                        new HealthRecordAttachment
                        {
                            Id = "roshta - Copy (2).jpg"
                        }
                    }
                }
                    );

                citizen1.HealthInfo.HealthRecords.Add(
                    new HealthRecord
                {
                    Id           = Guid.NewGuid().ToString(),
                    HealthInfoId = health1,
                    Diagnosis    = "كسر في عظام الساق نتيجة حادث موتوسيكل",
                    Medications  = "الادوية مرفقة مرفعة كصورة من الروشته",
                    Attachments  = new List <HealthRecordAttachment>
                    {
                        new HealthRecordAttachment
                        {
                            Id = "radiology - Copy (3).jpg"
                        },
                        new HealthRecordAttachment
                        {
                            Id = "roshta - Copy (3).jpg"
                        }
                    }
                }
                    );

                citizen1.HealthInfo.HealthRecords.Add(
                    new HealthRecord
                {
                    Id           = Guid.NewGuid().ToString(),
                    HealthInfoId = health1,
                    Diagnosis    = "كسر في عظام الساق نتيجة حادث موتوسيكل",
                    Medications  = "الادوية مرفقة مرفعة كصورة من الروشته",
                    Attachments  = new List <HealthRecordAttachment>
                    {
                        new HealthRecordAttachment
                        {
                            Id = "radiology - Copy (4).jpg"
                        },
                        new HealthRecordAttachment
                        {
                            Id = "roshta - Copy (4).jpg"
                        }
                    }
                }
                    );

                citizen1.HealthInfo.HealthRecords.Add(
                    new HealthRecord
                {
                    Id           = Guid.NewGuid().ToString(),
                    HealthInfoId = health1,
                    Diagnosis    = "كسر في عظام الساق نتيجة حادث موتوسيكل",
                    Medications  = "الادوية مرفقة مرفعة كصورة من الروشته",
                    Attachments  = new List <HealthRecordAttachment>
                    {
                        new HealthRecordAttachment
                        {
                            Id = "radiology - Copy.jpg"
                        },
                        new HealthRecordAttachment
                        {
                            Id = "roshta - Copy.jpg"
                        }
                    }
                }
                    );


                await _context.SaveChangesAsync();
            }