public GenderTypeEntity Create(GenderTypeEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { return provider.Insert<GenderTypeEntity>(entity); } }
public static GenderTypeEntity GetItemForInsert() { GenderTypeEntity entity = new GenderTypeEntity() { Description = "Male", DeletedDate = DateTime.MinValue }; return entity; }
public GenderTypeEntity Update(GenderTypeEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { GenderTypeEntity 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<GenderTypeEntity>(entityToUpdate); return entityToUpdate; } }
public GenderTypeEntity Delete(GenderTypeEntity entity) { entity.DeletedDate = DateTime.UtcNow; return Update(entity); }
private GenderTypeEntity UpdateProperties(GenderTypeEntity entity, GenderTypeEntity entityToUpdate) { entityToUpdate.Description = entity.Description; entityToUpdate.DeletedDate = entity.DeletedDate; return entityToUpdate; }
private static void CreateGenderTypes() { GenderTypeRepository repository = new GenderTypeRepository(ConfigSettings.MySqlDatabaseConnectionName); GenderTypeEntity entity = new GenderTypeEntity() { Description = "Manlijk", DeletedDate = DateTime.MinValue }; GenderTypeEntity mEntity = new GenderTypeEntity() { Description = "Vrouwlijk", DeletedDate = DateTime.MinValue }; entity = repository.Create(entity); mEntity = repository.Create(mEntity); _genderTypeEntities.Add(entity); _genderTypeEntities.Add(mEntity); }