Last active
January 24, 2017 20:10
-
-
Save jpolvora/22d8302f55075559fc89214f56a9de56 to your computer and use it in GitHub Desktop.
esqueminha pseudo java/C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiClient { | |
private string connectionString; | |
ctor(String connectionString) { | |
this.connectionString = connectionString; | |
} | |
public string FazAlgumaCoisa(string parametros) { | |
using (var conexao = new ConexaoComDb(connectionString)) { | |
return conexao.PegaDados(parametros); | |
} | |
} | |
} | |
class Business { | |
private ApiClient apiclient; | |
ctor(ApiClient apiclient) { | |
this.apiClient = apiclient; | |
} | |
public bool LeEImprime(string parametros) { | |
try { | |
//valida parâmetros | |
if (string.IsNullOrWhiteSpace(parametros)) return false; | |
var result = apiclient.FazAlgumaCoisa(parametros); | |
if (result != null) { | |
ChamaImpressora(); | |
return true; | |
} | |
return false; | |
} | |
catch { | |
return false; | |
} | |
} | |
} | |
public class FormPrincipal { | |
private Business business; | |
ctor(Business business) { | |
this.business = business; | |
} | |
public void ButtonClickHandler(object sender, EventArgs args) { | |
var parametros = textBox1.Text; | |
var result = business.LeEImprime(parametros); | |
if (result == true) { | |
ShowMessage("Função executada com sucesso."); | |
} | |
} | |
} | |
class Program { | |
public static void main() { | |
var connectionString = LerConfiguration["ConnectionString"]; | |
var apiclient = new ApiClient(connectionString); | |
var business = new Business(apiclient); | |
var formprincipal = new FormPrincipal(business); | |
formprincipal.Show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment