This file contains 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
private int[] dataSetToArray(DataSet dataset) | |
{ | |
return dataset.Tables[0].Select() | |
.Select(row => Convert.ToInt32(row["ANO"])) | |
.ToArray(); | |
} |
This file contains 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
-- inserindo categorias | |
insert into categoria (nome) values ('categoria ') | |
go 2000 | |
-- inserindo produtos até demais... | |
declare @i int = 0 | |
while @i < 100000 | |
begin | |
insert into produto (nome, preco, categoria_id) |
This file contains 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
select count(*) from categoria c | |
left outer join produto p on c.Id = p.categoria_id | |
where p.id is null |
This file contains 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
select count(*) from categoria | |
where id not in (select categoria_id from produto) |
This file contains 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
create table categoria ( | |
id int not null identity primary key, | |
nome varchar(100) not null, | |
) | |
create table produto ( | |
id int not null identity primary key, | |
nome varchar(100) not null, | |
preco money not null, | |
categoria_id int not null foreign key references categoria(id) |
This file contains 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
@section estilo { | |
<link href="@Url.Content("~/Scripts/uploadify/uploadify.css")" rel="stylesheet" type="text/css" /> | |
<link href="@Url.Content("~/Content/themes/smoothness/jquery-ui.css")" rel="stylesheet" type="text/css" /> | |
<link href="@Url.Content("~/Content/jquery.Jcrop.css")" rel="stylesheet" type="text/css" /> | |
} | |
@section scripts { | |
@JavaScriptHelper.CadastroDeCurso() @* Isto não deveria estar aqui *@ | |
} | |
@using (Html.BeginForm("Cadastrar", "Curso", FormMethod.Post, new { id = "frmCadastro", enctype = "multipart/form-data" })) | |
{ |
This file contains 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
[HttpPost] | |
public ActionResult AgendarPagamento(AgendamentoDePagamentoViewModel viewModel) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
var contas = recuperarContasAPagar(); | |
viewModel.MontarSelectListDeContas(contas); | |
return View(viewModel); | |
} |
This file contains 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
public ActionResult AgendarPagamento() | |
{ | |
var contas = recuperarContasAPagar(); | |
var viewModel = new AgendamentoDePagamentoViewModel(contas); | |
return View(viewModel); | |
} |
This file contains 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
public class AgendamentoDePagamentoViewModel | |
{ | |
public AgendamentoDePagamentoViewModel() {} // construtor vazio necessario para para o modelbinder | |
public AgendamentoDePagamentoViewModel(IEnumerable<Conta> contas) | |
{ | |
Contas = MontarSelectListDeContas(contas); | |
} | |
public SelectList Contas { get; set; } |
This file contains 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
[ComparaPropriedades("Senha", "ConfirmacaoDaSenha", ErrorMessage="A confirmação da senha não bate com a senha original")] | |
public class CadastroDeLoginViewModel | |
{ | |
public string Login { get; set; } | |
public string Senha { get; set; } | |
public string ConfirmacaoDaSenha { get; set; } | |
} |