public Imovel NovoImovel(Imovel I) { try { //Verifica se a descrição do Imóvel esta em branco if (I.NomeImovel == null) { throw new Exception("Ops! Preencha o campo nome do Imóvel"); } else { //Passa a data e hora para o campo DataInclusao ImovelRepositorio ir = new ImovelRepositorio(); I.Ativo = true; I.DataInclusao = DateTime.Now; I.DataAlteracao = null; ir.Insert(I); return(I); } } catch (Exception e) { throw e; } }
private void Form1Load(object sender, System.EventArgs e) { var imovelRepositorio = new ImovelRepositorio(); var imoveis = imovelRepositorio.ListarTodos(); this.ImoveisGridView.Carregar(imoveis); }
public ActionResult Salvar(LaudoViewModel viewModel) { string mensagem; WorkLifetimeManager.Value.BeginTransaction(IsolationLevel.Serializable); try { var laudo = LaudoRepositorio.Obter(WorkLifetimeManager.Value, viewModel.LaudoId); AtualizarLaudo(laudo, viewModel); ImovelRepositorio.Salvar(WorkLifetimeManager.Value, laudo.Imovel); LaudoRepositorio.Salvar(WorkLifetimeManager.Value, laudo); WorkLifetimeManager.Value.Commit(); mensagem = "Operação efetuada com sucesso!"; } catch (Exception ex) { WorkLifetimeManager.Value.Rollback(); mensagem = "Não foi possível efetuar alteração: " + ex.InnerException; } var laudos = BuscarLaudosPorStatus(viewModel.StatusLaudo); return(viewModel.StatusLaudo == EnumStatusLaudo.Importado.ToString() ? PartialView("ImportarOS") : PartialView("Lista", new ListaLaudoViewModel(viewModel.StatusLaudo, laudos, mensagem))); }
private void InserirButtonClick(object sender, System.EventArgs e) { var imovelRepositorio = new ImovelRepositorio(); var imovel = new Imovel { Modalidade = (Modalidade)this.modalidadeComboBox.SelectedIndex, Tipo = (Tipo)this.tipoComboBox.SelectedIndex, Proprietario = this.proprietarioTextBox.Text }; imovelRepositorio.Inserir(imovel); var imoveis = imovelRepositorio.ListarTodos(); this.ImoveisGridView.Carregar(imoveis); }
//Lista todas as Cidades public List <Imovel> TodosImoveis() { try { ImovelRepositorio ir = new ImovelRepositorio(); List <Imovel> i = ir.Todos(); if (i == null) { throw new Exception("Nenhum Imóvel Selecionado"); } return(i); } catch (Exception e) { throw e; } }