public EntityRelationshipEntity Create(EntityRelationshipEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { return provider.Insert<EntityRelationshipEntity>(entity); } }
public static EntityRelationshipEntity GetItemForInsert() { EntityRelationshipEntity entity = new EntityRelationshipEntity() { Entity1Id = ContactDetailsHelpers.CreateEntity().Id, Entity2Id = ContactDetailsHelpers.CreateEntity().Id, InDate = DateTime.UtcNow, OutDate = DateTime.UtcNow.AddDays(30), Preferred = true, DeletedDate = DateTime.MinValue }; return entity; }
public EntityRelationshipEntity Update(EntityRelationshipEntity entity) { using (IDatabaseProvider provider = ProviderFactory.GetProvider(_connectionStringName)) { EntityRelationshipEntity 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<EntityRelationshipEntity>(entityToUpdate); return entityToUpdate; } }
public EntityRelationshipEntity Delete(EntityRelationshipEntity entity) { entity.DeletedDate = DateTime.UtcNow; return Update(entity); }
private EntityRelationshipEntity UpdateProperties(EntityRelationshipEntity entity, EntityRelationshipEntity entityToUpdate) { entityToUpdate.Entity1Id = entity.Entity1Id; entityToUpdate.Entity2Id = entity.Entity2Id; entityToUpdate.InDate = entity.InDate; entityToUpdate.OutDate = entity.OutDate; entityToUpdate.Preferred = entity.Preferred; entityToUpdate.DeletedDate = entity.DeletedDate; return entityToUpdate; }