public ActionResult Apagar(int id) { EnderecoRepository repositorio = new EnderecoRepository(); repositorio.Apagar(id); return(RedirectToAction("Index")); }
public void SelectAllClientes() { Console.WriteLine("\n****CONSULTAR TODOS OS CLIENTES****"); try { ClienteRepository repository = new ClienteRepository(); EnderecoRepository enderecoRepository = new EnderecoRepository(); List <Cliente> lista = repository.SelectAll(); foreach (var item in lista) { Console.WriteLine("Id do Cliente..: " + item.IdCliente); Console.WriteLine("Nome...........: " + item.Nome); Console.WriteLine("Data Nasc......: " + item.DataNascimento.ToString("dd/MM/yyyy")); Endereco endereco = enderecoRepository.SelectByIdCliente(item.IdCliente); if (endereco != null) { Console.WriteLine("Logradouro.....: " + endereco.Logradouro); Console.WriteLine("Bairro.........: " + endereco.Bairro); Console.WriteLine("Cidade.........: " + endereco.Cidade); Console.WriteLine("Estado.........: " + endereco.Estado); Console.WriteLine("Cep............: " + endereco.Cep); } Console.WriteLine("********************************\n"); } } catch (Exception e) { Console.WriteLine("\nErro: " + e.Message); } }
public void Delete(int id) { EnderecoRepository enderecoRepository; EnderecoModel endereco; try { if (id == 0) { throw new Exception("ID inválido"); } else { enderecoRepository = new EnderecoRepository(_loggerFactory, _config); endereco = Get(id); if (enderecoRepository != null) { enderecoRepository.Delete(id); } } } catch (Exception ex) { throw ex; } }
public ActionResult Delete(int id) { EnderecoRepository repository = new EnderecoRepository(); repository.Delete(id); return(RedirectToAction("Index")); }
public ActionResult ObterTodosPorJSON() { string[] colunasNomes = new string[3]; colunasNomes[0] = "e.cep"; colunasNomes[1] = "e.logradouro"; colunasNomes[2] = "c.nome"; string start = Request.QueryString["start"]; string length = Request.QueryString["length"]; string draw = Request.QueryString["draw"]; string search = '%' + Request.QueryString["search[value]"] + '%'; string orderColumn = Request.QueryString["order[0][column]"]; string orderDir = Request.QueryString["order[0][dir]"]; orderColumn = colunasNomes[Convert.ToInt32(orderColumn)]; EnderecoRepository repository = new EnderecoRepository(); List <Endereco> enderecos = repository.ObterTodosParaJSON(start, length, search, orderColumn, orderDir); int countEnderecos = repository.ContabilizarEnderecos(); int countFiltered = repository.ContabilizarEnderecosFiltrados(search); return(Content(JsonConvert.SerializeObject(new { data = enderecos, draw = draw, recordsTotal = countEnderecos, recordsFiltered = countFiltered }))); }
public ActionResult Editar(int id) { EnderecoRepository repositorio = new EnderecoRepository(); ViewBag.EnderecoEditar = repositorio.ObterPeloId(id); return(View()); }
public ActionResult Editar(int id) { Endereco endereco = new EnderecoRepository().ObterPeloId(id); ViewBag.Endereco = endereco; return(Content(JsonConvert.SerializeObject(endereco))); }
protected override void Filtrar() { if (!string.IsNullOrEmpty(Filter) && Filter.Length >= Settings.Default.MinLenghtPesquisa) { Collection = new ObservableCollection <Endereco>(EnderecoRepository.GetEnderecoRange(Filter, 0, Settings.Default.TakePesquisa)); } }
static void Main(string[] args) { Endereco obj = new Endereco(); obj.Rua = "Rue Cadillac"; obj.Numero = 4020; obj.Cep = "H1R1H8"; obj.Complemento = "Proximo ao metro Cadillac"; EnderecoRepository rep = new EnderecoRepository(); rep.Insert(obj); Console.WriteLine("Endereço gravado com sucesso!"); List <Endereco> lista = rep.SelectAll(); foreach (var item in lista) { Console.WriteLine("Rua: " + item.Rua); Console.WriteLine("Numero: " + item.Numero); Console.WriteLine("Cep: " + item.Cep); Console.WriteLine("Complemento: " + item.Complemento); Console.WriteLine("*********************************"); } Console.ReadKey(); }
public async void GetByIdAsync_Endereco_Test() { // Arrange var endereco = new Endereco { Id = Guid.Parse("c0b4493d-75dc-4f8f-8259-d10114831889"), Logradouro = "Avenida Atlantica, 4", Bairro = "Copacabana", Cidade = "Rio de Janeiro", Estado = "Rio de Janeiro", ClienteId = Guid.Parse("3ce3c638-88fb-492a-b6db-ae3ac3910d66") }; // Valid enderecoValidation.Validate(endereco).Errors.Should().BeNullOrEmpty(); using (var database = new InMemoryDbContext()) { // Moq var dbContext = database.DbContext(); database.Seed(endereco); // Act var enderecoRepository = new EnderecoRepository(dbContext); var result = await enderecoRepository.GetByIdAsync(endereco.Id); // Assert result.Logradouro.Should().Be(endereco.Logradouro); } }
public UnitOfWork(DataContext session) { _session = session.OpenSession(); Endereco = new EnderecoRepository(_session); Hotel = new HotelRepository(_session); Quarto = new QuartoRepository(_session); }
public void SelectByIdEndereco() { Console.WriteLine("****CONSULTAR ENDEREÇO POR ID****"); try { int id = EnderecoInput.LerIdEndereco(); EnderecoRepository repository = new EnderecoRepository(); Endereco endereco = repository.SelectById(id); if (endereco != null) { Console.WriteLine("Id do Endereço.: " + endereco.IdEndereco); Console.WriteLine("Logradouro.....: " + endereco.Logradouro); Console.WriteLine("Bairro.........: " + endereco.Bairro); Console.WriteLine("Cidade.........: " + endereco.Cidade); Console.WriteLine("Estado.........: " + endereco.Estado); Console.WriteLine("CEP............: " + endereco.Cep); Console.WriteLine("Id do Cliente..: " + endereco.IdCliente); Console.WriteLine("---"); } else { Console.WriteLine("ENDEREÇO NÃO FOI ENCONTRADO"); } } catch (Exception e) { Console.WriteLine("Erro: " + e.Message); } }
public void SelectAllEnderecos() { Console.WriteLine("****CONSULTAR TODOS OS ENDEREÇOS****"); try { EnderecoRepository repository = new EnderecoRepository(); List <Endereco> lista = repository.SelectAll(); foreach (var item in lista) { Console.WriteLine("Id do Endereço.: " + item.IdEndereco); Console.WriteLine("Logradouro.....: " + item.Logradouro); Console.WriteLine("Bairro.........: " + item.Bairro); Console.WriteLine("Cidade.........: " + item.Cidade); Console.WriteLine("Estado.........: " + item.Estado); Console.WriteLine("CEP............: " + item.Cep); Console.WriteLine("Id do Cliente..: " + item.IdCliente); Console.WriteLine("***********************************"); } } catch (Exception e) { Console.WriteLine("Erro: " + e.Message); } }
// GET: Endereco public ActionResult Index(string pesquisa) { EnderecoRepository repository = new EnderecoRepository(); List <Endereco> enderecos = repository.ObterTodos(pesquisa); ViewBag.Enderecos = enderecos; return(View()); }
public VendaController(VendaRepository vendaRepository, ClienteRepository clienteRepository, VeiculoRepository veiculoRepository, FormaPagamentoRepository formaPagamentoRepository, EnderecoRepository enderecoRepository) { this.clienteRepository = clienteRepository; this.vendaRepository = vendaRepository; this.veiculoRepository = veiculoRepository; this.formaPagamentoRepository = formaPagamentoRepository; this.enderecoRepository = enderecoRepository; }
public ClienteController(ClienteRepository _clienteRepository, VendaRepository _vendaRepository, EnderecoRepository _enderecoRepository, PerfomanceRepository _customRepository) { this._clienteRepository = _clienteRepository; this._vendaRepository = _vendaRepository; this._enderecoRepository = _enderecoRepository; this._customRepository = _customRepository; }
// GET: Endereco public ActionResult Index() { EnderecoRepository e = new EnderecoRepository(); Algoritmo algoritmo = new Algoritmo(); algoritmo.VerificarDestino(); return(View(repository.GetAll())); }
// GET: Endereco public ActionResult Index(string busca) { EnderecoRepository repositorio = new EnderecoRepository(); @ViewBag.ListaEnderecos = repositorio.ObterTodos(busca); return(View()); }
public ActionResult Editar(int id) { EnderecoRepository repository = new EnderecoRepository(); Endereco endereco = repository.ObterPeloId(id); ViewBag.Endereco = endereco; return(View()); }
public HomeController() { imagensDestaqueRepository = new ImagensDestaqueRepository(); noivosRepository = new NoivosRepository(); enderecoRepository = new EnderecoRepository(); fraseRepository = new FraseRepository(); imagensGaleriaRepository = new ImagensGaleriaRepository(); historiaRepository = new HistoriaRepository(); }
public void CadastrarEndereco(ParceiroEnderecoMd endereco) { var enderecoEntity = Mapper.Map <ParceiroEnderecoMd, ParceiroEndereco>(endereco); enderecoEntity.Location = GeoJson.Point(new GeoJson2DCoordinates(endereco.Latitude, endereco.Longitude)).ToBsonDocument(); var repository = new EnderecoRepository(); repository.Insert(enderecoEntity); }
public async void GetAllAsync_Enderecos_Test() { // Arrange var enderecos = new List <Endereco>() { new Endereco { Id = Guid.Parse("c0b4493d-75dc-4f8f-8259-d10114831889"), Logradouro = "Avenida Atlantica, 4", Bairro = "Copacabana", Cidade = "Rio de Janeiro", Estado = "Rio de Janeiro", ClienteId = Guid.Parse("3ce3c638-88fb-492a-b6db-ae3ac3910d66") }, new Endereco { Id = Guid.Parse("f245a61e-dd49-44c8-a1fb-f57247d244c2"), Logradouro = "Rua Haddock Lobo, 27", Bairro = "Tijuca", Cidade = "Rio de Janeiro", Estado = "Rio de Janeiro", ClienteId = Guid.Parse("8b90ec7b-20ea-413a-a4fc-2dbd40f7d2ed") }, new Endereco { Id = Guid.Parse("08c0fecb-1866-47e2-b059-0b61518bc6c4"), Logradouro = "Avenida Ataulfo de Paiva, 128", Bairro = "Leblon", Cidade = "Rio de Janeiro", Estado = "Rio de Janeiro", ClienteId = Guid.Parse("57e8dd30-01ef-48ba-baaf-3358fb2c0a81") }, }; // Valid foreach (var endereco in enderecos) { enderecoValidation.Validate(endereco).Errors.Should().BeNullOrEmpty(); } using (var database = new InMemoryDbContext()) { // Moq var dbContext = database.DbContext(); database.Seed(enderecos); // Act var enderecoRepository = new EnderecoRepository(dbContext); var result = await enderecoRepository.GetAllAsync(); // Assert result.Should().HaveCount(3); } }
public IActionResult Post(Endereco ende) { EnderecoRepository repository = new EnderecoRepository(); try { return(Ok(repository.CadastrarEndereco(ende))); } catch (Exception) { return(BadRequest("Endereco não cadastrado")); } }
public VendaController(VendaRepository _vendaRepository, ClienteRepository _clienteRepository, VeiculoRepository _veiculoRepository, FormaPagamentoRepository _formaPagamentoRepository, EnderecoRepository _enderecoRepository, PerfomanceRepository _perfomanceRepository, RodaRepository _rodaRepository, BancoRepository _bancoRepository, CorVeiculoRepository _corRepository) { this._clienteRepository = _clienteRepository; this._vendaRepository = _vendaRepository; this._veiculoRepository = _veiculoRepository; this._formaPagamentoRepository = _formaPagamentoRepository; this._enderecoRepository = _enderecoRepository; this._perfomanceRepository = _perfomanceRepository; this._rodaRepository = _rodaRepository; this._bancoRepository = _bancoRepository; this._corRepository = _corRepository; }
public ActionResult Update(Endereco endereco) { bool alterado = new EnderecoRepository().Alterar(endereco); int sucesso = 0; if (alterado == true) { sucesso = 1; } else { sucesso = 0; } return(Content(JsonConvert.SerializeObject(sucesso))); }
private DbFactory() { Conexao(); ClienteRepository = new ClienteRepository(Session); LoginRepository = new LoginRepository(Session); EnderecoRepository = new EnderecoRepository(Session); AdministradorRespository = new AdministradorRespository(Session); ProdutoRepository = new ProdutoRepository(Session); FabricanteRepository = new FabricanteRepository(Session); QuestionarioRepository = new QuestionarioRepository(Session); CarrinhoRepository = new CarrinhoRepository(Session); HistoricoBuscaRepository = new HistoricoBuscaRepository(Session); Lista_CompraRepository = new Lista_CompraRepository(Session); }
public ActionResult Store(string unidadeFederativa, string cidade, string lougradouro, string cep, int numero, string complemento) { Endereco endereco = new Endereco(); endereco.UnidadeFederativa = unidadeFederativa; endereco.Cidade = cidade; endereco.Logradouro = lougradouro; endereco.CEP = cep; endereco.Numero = numero; endereco.Complemento = complemento; EnderecoRepository repository = new EnderecoRepository(); repository.Inserir(endereco); return(RedirectToAction("Index")); }
private void grdPedido_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1 && e.ColumnIndex > -1) { var _pedido = (Pedido)grdPedido.Rows[e.RowIndex].DataBoundItem; PedidoItemRepository.PreencherProduto(_pedido.ItensPedido); _pedido.EnderecoEntrega = EnderecoRepository.ObterEnderecoEntregaPorPedido(_pedido.Id); FormPedido frmPedido = new FormPedido(_pedido); frmPedido.ShowDialog(); AtualizaFormulario(); } }
public ActionResult ObterTodosPorJSONToSelect2() { List <Endereco> enderecos = new EnderecoRepository().ObterTodosParaSelect(); var x = new object[enderecos.Count]; int i = 0; foreach (var endereco in enderecos) { x[i] = new { id = endereco.Id, text = endereco.Cidade.Nome + endereco.Logradouro + endereco.Numero }; i++; } return(Content(JsonConvert.SerializeObject(new { results = x }))); }
public PedidoTests() { _carrinhoRepository = new CarrinhoRepository(); _produtoRepository = new ProdutoRepository(); _produtoTeste1 = _produtoRepository.BuscarProduto("5eee43682677f2362887051c"); _produtoTeste2 = _produtoRepository.BuscarProduto("5eee5b117373bcd310902b22"); _usuarioRepository = new UsuarioRepository(); _usuarioTeste = _usuarioRepository.BuscarUsuario("5eed8d19f7cf570004d6f68f"); _enderecoRepository = new EnderecoRepository(); _enderecoTeste = _enderecoRepository.BuscarEndereco("5ee8d82a14128a00042a1b0a"); _pedidoRepository = new PedidoRepository(); }
public EnderecoBusiness(UnidadeDeTrabalho unidadeDeTrabalho) { repositorio = unidadeDeTrabalho.EnderecoRepository; }