public EntityEntity Create(EntityEntity entity)
		{
			using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName))
			{
				return provider.Insert<EntityEntity>(entity);
			}
		}
		public static EntityEntity GetItemForInsert()
		{
			EntityEntity entity = new EntityEntity()
			{
				Name = "Enitity1",
				EntityTypeId = ContactDetailsHelpers.CreateEntityType().Id,
				DeletedDate = DateTime.MinValue
			};

			return entity;
		}
		public EntityEntity Update(EntityEntity entity)
		{
			using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName))
			{
				EntityEntity 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<EntityEntity>(entityToUpdate);

				return entityToUpdate;
			}
		}
		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 CreateEntities()
		{
			EntityRepository repository = new EntityRepository(ConfigSettings.MySqlDatabaseConnectionName);

			EntityEntity entity = new EntityEntity()
			{
				EntityTypeId = _entityTypeEntities[0].Id,
				Name = "EntityType1",
				DeletedDate = DateTime.MinValue
			};
			EntityEntity mEntity = new EntityEntity()
			{
				EntityTypeId = _entityTypeEntities[1].Id,
				Name = "EntityType2",
				DeletedDate = DateTime.MinValue
			};

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

			_entityEntities.Add(entity);
			_entityEntities.Add(mEntity);
		}
		private static ContactDetail CreateGetContactDetails(EntityEntity entityEntity, 
			List<PersonEntity> personEntities)
		{
			ContactDetail contact = new ContactDetail
			{
				EntityId = entityEntity.Id
			};

			PersonEntity personEntity = null;
			if (entityEntity != null)
			{
				contact.EntityName = entityEntity.Name;
				contact.EntityTypeId = entityEntity.EntityTypeId;

				personEntity = personEntities.FirstOrDefault(x => x.EntityId == entityEntity.Id);
			}

			if (personEntity != null)
			{
				contact.PersonId = personEntity.Id;
				contact.OccupationNameId = personEntity.OccupationNameId;
				contact.TitleId = personEntity.TitleId;
				contact.GenderTypeId = personEntity.GenderTypeId;
				contact.SurnamePrefix = personEntity.SurnamePrefix;
				contact.Surname = personEntity.Surname;
				contact.MaidenNamePrefix = personEntity.MaidenNamePrefix;
				contact.Nationality = personEntity.Nationality;
				contact.DateOfBirth = personEntity.DateOfBirth;
				contact.PlaceOfBirth = personEntity.PlaceOfBirth;
			}
			return contact;
		}
		public EntityEntity Delete(EntityEntity entity)
		{
			entity.DeletedDate = DateTime.UtcNow;

			return Update(entity);
		}
		private EntityEntity UpdateProperties(EntityEntity entity, EntityEntity entityToUpdate)
		{
			entityToUpdate.EntityTypeId = entity.EntityTypeId;
			entityToUpdate.Name = entity.Name;
			entityToUpdate.DeletedDate = entity.DeletedDate;

			return entityToUpdate;
		}