Пример #1
0
        public string FindDates(PersonDb personDb)
        {
            string dates = null;

            if (personDb.BirthRangeStart != default || personDb.DeathRangeStart != default)
            {
                dates += " (";
                if (personDb.BirthRangeStart != default)
                {
                    dates += FindDateFromRange(personDb.BirthRangeStart, personDb.BirthRangeEnd);
                }

                if (personDb.DeathRangeStart != default)
                {
                    dates += " - " + FindDateFromRange(personDb.DeathRangeStart, personDb.DeathRangeEnd);
                }

                dates += ")";
            }

            return(dates);
        }
Пример #2
0
        public async Task AddPerson(PersonDb personDb)
        {
            if (personDb.NickName == null)
            {
                personDb.NickName = "";
            }

            if (personDb.PlaceOfBirth == null)
            {
                personDb.PlaceOfBirth = "";
            }

            if (personDb.PlaceOfDeath == null)
            {
                personDb.PlaceOfDeath = "";
            }

            if (personDb.Note == null)
            {
                personDb.Note = "";
            }

            if (personDb.Portrait == null)
            {
                personDb.Portrait = "";
            }


            var db = new MySqlConnection(_connectionString);

            try
            {
                await db.ExecuteAsync(@"
INSERT INTO People (
GedcomID, 
Gender,
PreferredName, 
GivenNames,
Surname,
BirthRangeStart,
BirthRangeEnd, 
PlaceOfBirth,
Dead,
DeathRangeStart,
DeathRangeEnd, 
PlaceOfDeath
) VALUES (
@GedcomID, 
@Gender,
@PreferredName, 
@GivenNames,
@Surname,
@BirthRangeStart,
@BirthRangeEnd, 
@PlaceOfBirth,
@Dead,
@DeathRangeStart,
@DeathRangeEnd, 
@PlaceOfDeath)", personDb);
            } catch (Exception e)
            {}
        }