Пример #1
0
        public async void TestAsync()
        {
            PersonsService service = new PersonsService();

            Person2 newPerson = new Person2(new User(), "Jonaitis", "199-11-21", "2018-11-21", "test");

            Console.WriteLine("person: " + newPerson);
            try
            {
                var response = await service.AddNewPersonAsync(newPerson);

                if (response != null)
                {
                    Console.WriteLine("Done");
                }
                else
                {
                    Console.WriteLine("Error");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error: " + ex);
            }

            /*     var response2 = await service.GetPersonsList();
             *
             *    foreach (Person2 person in response2)
             *        Console.WriteLine(person.Name);*/
        }
Пример #2
0
        public static void ShowGroup()
        {
            var characters = PersonsService.GetPersons();
            var groups     = from person in characters
                             where person.Age > 100
                             group person by person.Gender into genderGroups
                             group genderGroups by genderGroups.Count() into countedGroup
                             select new
            {
                Key   = countedGroup.Key,
                Count = countedGroup.Count(),
                Group = countedGroup
            };

            foreach (var persons in groups)
            {
                foreach (var person in persons.Group)
                {
                    foreach (var human in person)
                    {
                        Console.WriteLine(human);
                    }
                }
            }
        }
        public IHttpActionResult Create(CreatePerson command)
        {
            // Crée une nouvelle personne
            var servicePerson = new PersonsService();

            var newPerson = servicePerson.CreatePerson(command);

            return(Ok(newPerson));
        }
Пример #4
0
        public static void ShowProperty()
        {
            var characters = PersonsService.GetPersons();
            var persons    = characters.Select(x => new { PersonDescription = $"{x.FirstName}, {x.LastName}, { x.Gender} ,{ x.Age}" });

            foreach (var person in persons)
            {
                Console.WriteLine(person.PersonDescription);
            }
        }
        public static void ShowExtensionMethodSyntax()
        {
            var characters = PersonsService.GetPersons();

            var adults = characters.Where(character => character.Age > 20);

            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #6
0
        public static void ShowExtensionMethodSyntax()
        {
            var users = PersonsService.GetPersons();

            var adults = users.Where(n => n.Age > 30).OrderByDescending(x => x.Age).ThenBy(x => x.FirstName);;

            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #7
0
        public static void OrderByExtensionSyntax()
        {
            var characters = PersonsService.GetPersons();

            var adults = characters.Where(x => x.Age > 20).OrderByDescending(x => x.Gender).ThenBy(x => x.FirstName);

            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #8
0
        public static void ShowWhereWithExtensionSyntax()
        {
            var characters = PersonsService.GetPersons();

            var persons = characters.Where(x => x.FirstName.StartsWith("A") || x.LastName.Length == 5);

            foreach (var person in persons)
            {
                Console.WriteLine(person.ToString());
            }
        }
Пример #9
0
        public PeopleList()
        {
            InitializeComponent();

            _personsService = new PersonsService();

            namesView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {
                //PersonSelected?.Invoke(sender, new PersonSelectedEventArgs((Person)e.SelectedItem));
                MessagingCenter.Send(this, "PersonPicked", (Person)e.SelectedItem);
                Navigation.PopAsync();
            };
        }
Пример #10
0
        public static void ShowOrederBy()
        {
            var characters = PersonsService.GetPersons();

            var adults = from character in characters
                         orderby character.FirstName
                         select character;

            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #11
0
        public static void ShowBasicSyntaxLinq()
        {
            var characters = PersonsService.GetPersons();

            var adults = from character in characters
                         where character.Age > 20
                         select character;

            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #12
0
        public static void ShowConditionWithGender()
        {
            var characters = PersonsService.GetPersons();

            var adults = from character in characters
                         where character.Gender == true
                         select character;

            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #13
0
        public static void ShowWhereWithBasicSyntax()
        {
            var characters = PersonsService.GetPersons();

            var persons = from character in characters
                          where character.FirstName.StartsWith("A") &&
                          !character.LastName.StartsWith("S")
                          select character;

            foreach (var person in persons)
            {
                Console.WriteLine(person.ToString());
            }
        }
        public static void DefferedExecution()
        {
            var characters = PersonsService.GetPersons();

            var adults = characters.Where(character => character.FirstName.StartsWith("A"));

            characters.Add(new Person("Andrew", "Harlan", true, 37));

            //Запрос выполняется в момент его использования
            foreach (var adult in adults)
            {
                Console.WriteLine(adult.ToString());
            }
        }
Пример #15
0
        public static void GroupByExtensionSyntax()
        {
            var characters = PersonsService.GetPersons();

            var groups = characters.GroupBy(x => x.Gender);

            foreach (var group in groups)
            {
                foreach (var person in group)
                {
                    Console.WriteLine(person.ToString());
                }
            }
        }
Пример #16
0
        public static void ShowExplicitSelect()
        {
            var characters = PersonsService.GetPersons();

            var names = from character in characters
                        select character.FirstName;

            //var names = characters.Select(x => x.FirstName);

            foreach (var name in names)
            {
                Console.WriteLine(name);
            }
        }
Пример #17
0
        public static void ShowGroupBy()
        {
            var characters = PersonsService.GetPersons();

            var groups = from character in characters
                         group character by character.Gender;

            foreach (var group in groups)
            {
                foreach (var person in group)
                {
                    Console.WriteLine(person.ToString());
                }
            }
        }
Пример #18
0
        public AddPerson()
        {
            InitializeComponent();

            PersonVM                = new PersonViewModel();
            _personsService         = new PersonsService();
            _faceRecognitionService = new FaceRecognitionService();
            _faceDetectionService   = new FaceDetectionService();
            _imageResizerService    = DependencyService.Get <IImageResizerService>();

            _ImageSlots.Add(image1);
            _ImageSlots.Add(image2);
            _ImageSlots.Add(image3);

            NextPhotos.IsVisible = false;
            PrevPhotos.IsVisible = false;
        }
Пример #19
0
        public static void SelectAnonymousType()
        {
            var characters = PersonsService.GetPersons();

            var persons = from character in characters
                          select new
            {
                character.FirstName,
                character.Age
            };

            //var persons = characters.Select(x => new { x.FirstName, x.Age });

            foreach (var person in persons)
            {
                Console.WriteLine($"FirstName: {person.FirstName}, \tAge: {person.Age}");
            }
        }
Пример #20
0
        //Напишите запрос LINQ в котором сгрупируйте персонажей по возрасту
        //выведите группы в которых больше одного персонажа

        public static void GroupByInto()
        {
            var characters = PersonsService.GetPersons();

            var groups = from character in characters
                         group character by character.Age into ageGroups
                         where ageGroups.Count() > 1
                         select ageGroups;

            //var groups = characters.GroupBy(x => x.Age).Where(group => group.Count() > 1);

            foreach (var group in groups)
            {
                foreach (var person in group)
                {
                    Console.WriteLine(person.ToString());
                }
            }
        }
Пример #21
0
        public async Task SearchWorks()
        {
            var dbContextFactory = new InMemoryDbContextFactory();

            var firstUser = new TestUserContext();
            await firstUser.CreateUser(new AuthenticationService(firstUser, dbContextFactory), Nicknames[0]);

            foreach (var nickname in Nicknames.Skip(1))
            {
                var userContext = new TestUserContext();
                await userContext.CreateUser(new AuthenticationService(userContext, dbContextFactory), nickname);
            }

            var personsService = new PersonsService(firstUser, dbContextFactory);
            var persons        = await personsService.SearchPeopleByNickname("ExP");

            Assert.Equal(3, persons.Count);
            Assert.Equal(
                new[] { "Expiration", "Explorer", "The Experienced Dude" },
                persons.Select(x => x.Nickname).OrderBy(x => x).ToArray()
                );
        }
Пример #22
0
        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
            }
        }
Пример #23
0
 public PersonController(PersonsService ps)
 {
     _ps = ps;
 }