예제 #1
0
        public static void GetAllPeoplefirstAndLastNameOnly()
        {
            var mongoDB = new MongoCRUD("AddressBook");
            var records = mongoDB.LoadRecords <NameModel>("Users");

            foreach (var record in records)
            {
                Console.WriteLine($"{ record.FirstName } { record.LastName }");
            }
        }
예제 #2
0
        public static void DeletePerson()
        {
            Guid personGuid  = ConsoleInputHelper.GetGuidFromConsole("Enter Guid of Person: ");
            var  mongoDB     = new MongoCRUD("AddressBook");
            var  personFound = mongoDB.LoadRecordById <PersonModel>("Users", personGuid);

            if (personFound != null)
            {
                mongoDB.DeleteRecord <PersonModel>("Users", personGuid);
            }
        }
예제 #3
0
        public static void UpdatePerson()
        {
            Guid     personGuid = ConsoleInputHelper.GetGuidFromConsole("Enter Guid of Person: ");
            DateTime dob        = ConsoleInputHelper.GetDateTimeFromConsole();

            var mongoDB = new MongoCRUD("AddressBook");
            var person  = mongoDB.LoadRecordById <PersonModel>("Users", personGuid);

            person.DateOfBirth = dob;
            mongoDB.UpsertRecord("Users", person.Id, person);
        }
예제 #4
0
        public static void InsertPerson()
        {
            string firstName = ConsoleInputHelper.GetStringFromConsole("Enter first name: ");
            string lastName  = ConsoleInputHelper.GetStringFromConsole("Enter last name: ");

            PersonModel person = new PersonModel
            {
                FirstName = firstName,
                LastName  = lastName,
            };

            var mongoDB = new MongoCRUD("AddressBook");

            mongoDB.InsertRecord("Users", person);
        }
예제 #5
0
        public static void GetAllPeople()
        {
            var mongoDB = new MongoCRUD("AddressBook");
            var records = mongoDB.LoadRecords <PersonModel>("Users");

            foreach (var record in records)
            {
                Console.WriteLine($"{ record.Id }: { record.FirstName } { record.LastName }");
                if (record.PrimaryAddress != null)
                {
                    Console.WriteLine(record.PrimaryAddress.City);
                }
                if (record.DateOfBirth.Year != 1)
                {
                    Console.WriteLine(record.DateOfBirth);
                }
            }
        }