public PersonEntity Create(PersonEntity entity)
		{
			using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName))
			{
				return provider.Insert<PersonEntity>(entity);
			}
		}
		public PersonEntity Update(PersonEntity entity)
		{
			using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName))
			{
				PersonEntity entityToUpdate = Read(entity.Id);
				if (entityToUpdate == null)
					throw new DataAccessException("Item not found"); //  This should not happen seeing that validation should check.

				entityToUpdate = UpdateProperties(entity, entityToUpdate);

				provider.Update<PersonEntity>(entityToUpdate);

				return entityToUpdate;
			}
		}
		public static PersonEntity GetItemForInsert()
		{
			PersonEntity entity = new PersonEntity()
			{
				EntityId = ContactDetailsHelpers.CreateEntity().Id,
				OccupationNameId = ContactDetailsHelpers.CreateOccupationName().Id,
				TitleId = ContactDetailsHelpers.CreateTitle().Id,
				SurnamePrefix = "Von",
				Surname = "SurnamePerson1",
				MaidenNamePrefix = "",
				Nationality = "NL",
				PlaceOfBirth = "Sasol",
				DeletedDate = DateTime.MinValue
			};

			return entity;
		}
		public ContactDetail Post(ContactDetail request)
		{
			PersonRepository personRepository = GetPersonRepository();
			EntityRepository entityRepository = GetEntityRepository();

			PersonEntity personEntity = new PersonEntity();
			EntityEntity entity = new EntityEntity();

			//Create entity 
			entity.Name = request.EntityName;
			entity.EntityTypeId = request.EntityTypeId;
			entity.DeletedDate = DateTime.MinValue;

			entity = entityRepository.Create(entity);

			personEntity.EntityId = entity.Id;
			personEntity.OccupationNameId = request.OccupationNameId;
			personEntity.TitleId = request.TitleId;
			personEntity.GenderTypeId = request.GenderTypeId;
			personEntity.SurnamePrefix = request.SurnamePrefix;
			personEntity.Surname = request.Surname;
			personEntity.MaidenNamePrefix = request.MaidenNamePrefix;
			personEntity.Nationality = request.Nationality;
			personEntity.DateOfBirth = request.DateOfBirth;
			personEntity.PlaceOfBirth = request.PlaceOfBirth;
			personEntity.DeletedDate = DateTime.MinValue;

			try
			{
				personEntity = personRepository.Create(personEntity);
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex);
			}
			
			List<PersonEntity> personEntities = personRepository.Read();

			return CreateGetContactDetails(entity, personEntities);
		}
		private static void CreatePerson()
		{
			PersonRepository repository = new PersonRepository(ConfigSettings.MySqlDatabaseConnectionName);

			PersonEntity entity = new PersonEntity()
			{
				EntityId = _entityEntities[0].Id,
				OccupationNameId = _occupationNameEntities[0].Id,
				TitleId = _titleEntities[0].Id,
				GenderTypeId = _genderTypeEntities[0].Id,
				SurnamePrefix = "van",
				Surname = "Riebeeck",
				MaidenNamePrefix = string.Empty,
				Nationality = "nl",
				DateOfBirth = DateTime.UtcNow.AddYears(-34),
				PlaceOfBirth = "Houten",
				DeletedDate = DateTime.MinValue
			};
			PersonEntity mEntity = new PersonEntity()
			{
				EntityId = _entityEntities[1].Id,
				OccupationNameId = _occupationNameEntities[1].Id,
				TitleId = _titleEntities[1].Id,
				GenderTypeId = _genderTypeEntities[1].Id,
				SurnamePrefix = string.Empty,
				Surname = "Stel",
				MaidenNamePrefix = "",
				Nationality = "BL",
				DateOfBirth = DateTime.UtcNow.AddYears(-37),
				PlaceOfBirth = "Zeist",
				DeletedDate = DateTime.MinValue
			};

			entity = repository.Create(entity);
			mEntity = repository.Create(mEntity);

			_personEntities.Add(entity);
			_personEntities.Add(mEntity);
		}
		public PersonEntity Delete(PersonEntity entity)
		{
			entity.DeletedDate = DateTime.UtcNow;

			return Update(entity);
		}
		private PersonEntity UpdateProperties(PersonEntity entity, PersonEntity entityToUpdate)
		{
			entityToUpdate.EntityId = entity.EntityId;
			entityToUpdate.OccupationNameId = entity.OccupationNameId;
			entityToUpdate.TitleId = entity.TitleId;
			entityToUpdate.SurnamePrefix = entity.SurnamePrefix;
			entityToUpdate.Surname = entity.Surname;
			entityToUpdate.MaidenNamePrefix = entity.MaidenNamePrefix;
			entityToUpdate.Nationality = entity.Nationality;
			entityToUpdate.DateOfBirth = entity.DateOfBirth;
			entityToUpdate.PlaceOfBirth = entity.PlaceOfBirth;
			entityToUpdate.DeletedDate = entity.DeletedDate;

			return entityToUpdate;
		}