public Interesado Consultar(int id) { Interesado interesado = context.Interesados.Where((i) => i.Id == id).FirstOrDefault(); interesado.Facturas = facturaService.ConsultarPorInteresado(interesado.Id); return(interesado); }
public GuardarInteresadoResponse Guardar(Interesado interesado) { try { var usuario = usuarioService.Consultar(interesado.IdUsuario); if (usuario != null) { interesado.Usuario = usuario; interesado.IdUsuario = usuario.Id; } else { var response = usuarioService.Guardar(interesado.Usuario); if (response.Error) { return(new GuardarInteresadoResponse(usuarioService.Guardar(interesado.Usuario).Mensaje, true)); } usuarioService.Guardar(interesado.Usuario); interesado.IdUsuario = response.Usuario.Id; } context.Interesados.Add(interesado); context.SaveChanges(); return(new GuardarInteresadoResponse(interesado, "Interesado guardado con éxito", false)); } catch (System.Exception e) { return(new GuardarInteresadoResponse($"Ha ocurrido un error en el servidor. {e.Message} Por favor, vuelva a internar más tarde", true)); } }
private void btBuscar_Click(object sender, EventArgs e) { try { if (gvResultado.SelectedRows.Count == 1) { Interesado interesado = (Interesado)gvResultado.SelectedRows[0].DataBoundItem; frmInteresado frmInteresado = new frmInteresado(); frmInteresado.Interesado = interesado; frmInteresado.MdiParent = (Form)this.Parent.Parent; Panel p = (Panel)this.Parent.Parent.Controls.Find("pnlMdi", true).First(); p.Controls.Add(frmInteresado); frmInteresado.BringToFront(); frmInteresado.StartPosition = FormStartPosition.Manual; //int width = this.Controls.Find("netBarControl1", true)[0].Width; frmInteresado.Location = new Point(120, 0); this.Close(); frmInteresado.Show(); } } catch (Exception ex) { Helper.EnviarNotificacion(ex); throw; } }
private void btGuardar_Click(object sender, EventArgs e) { try { string errores = ValidarCamposObligatorios(); if (errores == string.Empty) { if (Interesado == null) { Interesado = new Interesado(); } eAmbientes ambientes; Enum.TryParse <eAmbientes>(cbAmbientes.SelectedValue.ToString(), out ambientes); Interesado.Ambientes = (int)ambientes; eTipoInmueble tipoInmueble; Enum.TryParse <eTipoInmueble>(cbTipoInmueble.SelectedValue.ToString(), out tipoInmueble); Interesado.TipoDeInmueble = (int)tipoInmueble; eTipoOperacion tipoOperacion; Enum.TryParse <eTipoOperacion>(cbTipoOperacion.SelectedValue.ToString(), out tipoOperacion); Interesado.TipoDeOperacion = (int)tipoOperacion; eMoneda tipoMoneda; Enum.TryParse <eMoneda>(cbMoneda.SelectedValue.ToString(), out tipoMoneda); Interesado.TipoDeMoneda = (int)tipoMoneda; Interesado.Localidad = cbLocalidad.SelectedValue.ToString(); Interesado.Nombre = txNombre.Text; Interesado.Apellido = txApellido.Text; Interesado.Email = txEmail.Text; Interesado.Telefono = txTelefono.Text; Interesado.MontoDesde = 0m; Interesado.MontoHasta = numHasta.Value; Interesado.Observaciones = txObservaciones.Text; Interesado.Disponible = checkDisponible.Checked; //Ahora que ya tenes el interesado guardado lo tenes que mandar al web service para que lo guarde en la base de datos: ServiceHelper.ws.GuardarInteresado(Interesado); MessageBox.Show("Interesado guardado correctamente"); ServiceHelper.ws.NotificarSobreInmuebleAsync(Interesado, ServiceHelper.ValorDolar); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show(errores, "Errores de Validación"); } } catch (Exception ex) { EmailHelper.EnviarNotificacion(ex); throw ex; } }
public EditarInteresadoResponse Editar(Interesado interesadoOld, Interesado interesado) { testWebContext.Interesados.Remove(interesadoOld); testWebContext.Interesados.Add(interesado); testWebContext.SaveChanges(); return(new EditarInteresadoResponse(interesado, "Interesado modificado correctamente.")); }
public GuardarFacturaResponse Guardar(Factura factura) { try { Interesado interesado = context.Interesados.Find(factura.IdInteresado); if (interesado == null && factura.Tipo == "venta") { factura.IdInteresado = 0; } foreach (Detalle detalle in factura.ObtenerDetalles()) { if (detalleService.Guardar(detalle).Error) { return(new GuardarFacturaResponse(detalleService.Guardar(detalle).Mensaje, true)); } } factura.CalcularTotales(); context.Facturas.Add(factura); context.SaveChanges(); return(new GuardarFacturaResponse(factura, "Factura guardada con éxito", false)); } catch (System.Exception e) { return(new GuardarFacturaResponse($"Ha ocurrido un error en el servidor. {e.Message} Por favor, vuelva a internar más tarde", true)); } }
public GuardarResponse Guardar(Usuario usuario) { try{ var Respuesta = _TiendaContext.interesados.Find(usuario.Identificacion); if (Respuesta == null) { Interesado interesado = new Interesado(); interesado.Identificacion = usuario.Identificacion; interesado.Nombres = usuario.Nombres; interesado.Apellidos = usuario.Apellidos; interesado.User = usuario.User; interesado.Pass = usuario.Pass; interesado.Sexo = usuario.Sexo; _TiendaContext.interesados.Add(interesado); _TiendaContext.SaveChanges(); return(new GuardarResponse(interesado)); } else { return(new GuardarResponse("Ya se encuentra este usuario", "EXISTE")); } } catch (Exception e) { return(new GuardarResponse($"Error aplicación: {e.Message}", "ERROR")); } }
public InteresadoVista(Interesado interesado) { identificacion = interesado.identificacion; Nombres = interesado.Nombres; Apellidos = interesado.Apellidos; Telefono = interesado.Telefono; FechaRegistro = interesado.FechaRegistro; }
private Interesado MapearAInteresado(InteresadoInputModel interesadoInputModel) { var interesado = new Interesado { Usuario = interesadoInputModel.Usuario }; return(interesado); }
public InteresadoViewModel(Interesado interesado) { Id = interesado.Id; Nombre = interesado.Nombre; Celular = interesado.Celular; Correo = interesado.Correo; Contrasena = interesado.Contrasena; Facturas = interesado.Facturas; }
public ActionResult <InteresadoViewModel> Delete(string id) { Interesado interesado = interesadoService.ConsultarId(id).Interesado; if (interesado == null) { return(BadRequest("Interesado no encontrado")); } return(Ok(interesadoService.Eliminar(interesado).Interesado)); }
public Respuesta <Interesado> Buscar(string Identificacion) { Interesado interesado = Context.Interesados.FirstOrDefault(i => i.identificacion == Identificacion); if (interesado != null) { return(new Respuesta <Interesado>(interesado)); } return(new Respuesta <Interesado>("No existe")); }
public Respuesta <FacturaVenta> generarFactura(Interesado interesado, List <DispositivoMovil> dispositivos) { FacturaVenta factura = new FacturaVenta(); foreach (var item in dispositivos) { factura.AgregarDetallesFactura(item); } factura.IdInteresado = interesado.identificacion; return(new Respuesta <FacturaVenta>(factura)); }
public ActionResult <InteresadoViewModel> Put(string id, Interesado interesado) { Interesado interesadoConsulta = interesadoService.ConsultarId(id).Interesado; if (interesadoConsulta == null) { return(BadRequest("No se encontro al usuario interesado.")); } Interesado response = interesadoService.Editar(interesadoConsulta, interesado).Interesado; return(Ok(response)); }
private Interesado MapToInteresado(InteresadoInputModel interesadoInputModel) { Interesado interesado = new Interesado { Nombre = interesadoInputModel.Nombre, Celular = interesadoInputModel.Celular, Correo = interesadoInputModel.Correo, Contrasena = interesadoInputModel.Contrasena }; return(interesado); }
public Respuesta <Interesado> Guardar(Interesado interesado) { try { Context.Interesados.Add(interesado); Context.SaveChanges(); return(new Respuesta <Interesado>(interesado)); } catch (Exception e) { return(new Respuesta <Interesado>($"Error de la aplicacion: {e.Message}")); } }
public void crearUsuario(Interesado interesado) { usuarioService = new UsuarioService(testWebContext); usuario = new Usuario(); usuario.Id = interesado.Id; usuario.Nombre = interesado.Nombre; usuario.Correo = interesado.Correo; usuario.Contrasena = interesado.Contrasena; usuario.Celular = interesado.Celular; usuario.Rol = "interesado"; Interesado interesadoBuscado = ConsultarId(interesado.Id.ToString()).Interesado; usuarioService.Guardar(usuario); }
private void btEliminar_Click(object sender, EventArgs e) { Interesado interesado = new Interesado(); if (ServiceHelper.ws.EliminarInteresado(Interesado)) { //tu metodo es de tipo void, por lo que no retorna nada, ese return no puede ir //lo que tenes que hacer es mostrar un cartel MessageBox.Show("El Interesado se elimino Correctamente", "Interesado"); this.Close(); } else { MessageBox.Show("El Interesado NO se elimino", "Interesado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ConsultarInteresadoResponse ConsultarId(string id) { try { Interesado interesadoBuscado = testWebContext.Interesados.Find(id); if (interesadoBuscado != null) { return(new ConsultarInteresadoResponse(interesadoBuscado, "Interesado encontrado")); } return(new ConsultarInteresadoResponse("Interesado no encontrado")); } catch (Exception e) { return(new ConsultarInteresadoResponse($"Ocurrió un error {e.Message}")); } }
public ActionResult <InteresadoViewModel> Post(InteresadoInputModel interesadoInputModel) { Interesado interesado = MapToInteresado(interesadoInputModel); var response = interesadoService.Guardar(interesado); if (response.Error) { ModelState.AddModelError("Error al registrar al usuario interesado", response.Mensaje); var detallesProblema = new ValidationProblemDetails(ModelState) { Status = StatusCodes.Status400BadRequest }; return(BadRequest(detallesProblema)); } return(Ok(response.Interesado)); }
private void FiltrarResultados(object sender, EventArgs e) { try { bool filtroAlgo = false; Interesado interesado = new Interesado(); interesado.Nombre = txNombre.Text; interesado.Email = txEmail.Text; interesado.Telefono = txTelefono.Text; List <Interesado> aux = new List <Interesado>(); if (!string.IsNullOrEmpty(interesado.Nombre)) { aux.AddRange(Interesados.Where(x => x.Nombre.ToUpperInvariant().Contains(interesado.Nombre.ToUpperInvariant())).ToList()); filtroAlgo = true; } if (!string.IsNullOrEmpty(interesado.Telefono)) { aux.AddRange(Interesados.Where(x => x.Telefono.ToUpperInvariant().Contains(interesado.Telefono.ToUpperInvariant())).ToList()); filtroAlgo = true; } if (!string.IsNullOrEmpty(interesado.Email)) { aux.AddRange(Interesados.Where(x => x.Email.ToUpperInvariant().Contains(interesado.Email.ToUpperInvariant())).ToList()); filtroAlgo = true; } if (!filtroAlgo) { aux.AddRange(Interesados); } aux = aux.Distinct().ToList(); gvResultado.DataSource = aux; gvResultado.Columns["Id"].Visible = false; gvResultado.Columns["FullName"].Visible = false; } catch (Exception) { } }
public GuardarInteresadoResponse Guardar(Interesado interesado) { try { Interesado interesadoBuscado = testWebContext.Interesados.Find(interesado.Id); if (interesadoBuscado != null) { return(new GuardarInteresadoResponse("Interesado ya registrado.")); } testWebContext.Interesados.Add(interesado); testWebContext.SaveChanges(); crearUsuario(interesado); return(new GuardarInteresadoResponse(interesado, "Interesado guardado correctamente")); } catch (Exception e) { return(new GuardarInteresadoResponse($"Ocurrió un error {e.Message}")); } }
public void ActualizarInfo(Interesado interesado) { Interesado InteresadoEncontrado = Context.Interesados.FirstOrDefault(i => i.identificacion == i.identificacion); if (InteresadoEncontrado.Nombres != interesado.Nombres) { InteresadoEncontrado.Nombres = interesado.Nombres; } if (InteresadoEncontrado.Apellidos != interesado.Apellidos) { InteresadoEncontrado.Apellidos = interesado.Apellidos; } if (InteresadoEncontrado.Telefono != interesado.Telefono) { InteresadoEncontrado.Telefono = interesado.Telefono; } Context.Interesados.Update(InteresadoEncontrado); Context.SaveChanges(); }
private void AnyadirEmpleadoInteresado() { if (countEmpleados <= TAM_MAX) { Console.WriteLine("Añadir empleado interesado"); Console.WriteLine("Dime su nombre"); string nombre = Console.ReadLine(); Console.WriteLine("Dime su especialidad"); string sector = Console.ReadLine(); Console.WriteLine("Dime su fecha"); string fecha = Console.ReadLine(); empleados[countEmpleados] = new Interesado(nombre, sector, fecha); countEmpleados++; } else { Console.WriteLine("no cabe"); } }
public EditarInteresadoResponse Editar(int id, Interesado interesadoActualizado) { try { var interesadoAActualizar = context.Interesados.Where((i) => i.Id == id).FirstOrDefault(); if (interesadoAActualizar != null) { interesadoAActualizar.Facturas = interesadoActualizado.Facturas; interesadoAActualizar.Usuario = interesadoActualizado.Usuario; interesadoAActualizar.IdUsuario = interesadoAActualizar.IdUsuario; context.Interesados.Update(interesadoAActualizar); context.SaveChanges(); return(new EditarInteresadoResponse(interesadoAActualizar, "Interesado editado correctamente", false)); } else { return(new EditarInteresadoResponse("Interesado no encontrado", true)); } } catch (Exception e) { return(new EditarInteresadoResponse($"Ocurrió un error al editar el interesado {e.Message}", true)); } }
public GuardarInteresadoResponse(Interesado interesado, string mensaje, bool error) { Interesado = interesado; Mensaje = mensaje; Error = error; }
public EliminarInteresadoResponse Eliminar(Interesado interesado) { testWebContext.Interesados.Remove(interesado); testWebContext.SaveChanges(); return(new EliminarInteresadoResponse(interesado, "Interesado eliminado correctamente.")); }
public ConsultarInteresadoResponse(Interesado interesado, string mensaje) { Mensaje = mensaje; Interesado = interesado; Error = false; }
private void BtGuardar_Click(object sender, EventArgs e) { Interesado interesado = new Interesado(); interesado.Nombre = txNombre.Text; interesado.Apellido = txApellido.Text; interesado.Email = txEmail.Text; interesado.Disponible = true; interesado.Telefono = txTelefono.Text; interesado.Observaciones = txObservaciones.Text; interesado.MontoHasta = Convert.ToDecimal(txMonto.Text); if (spnTipoMoneda.SelectedItem.ToString() == "Pesos") { interesado.TipoDeMoneda = 1; } else { interesado.TipoDeMoneda = 2; } if (spnTipoInmueble.SelectedItem.ToString() == "Terreno") { interesado.TipoDeInmueble = 1; } else if (spnTipoInmueble.SelectedItem.ToString() == "Departamento") { interesado.TipoDeInmueble = 2; } else if (spnTipoInmueble.SelectedItem.ToString() == "Casa") { interesado.TipoDeInmueble = 3; } else if (spnTipoInmueble.SelectedItem.ToString() == "Quinta") { interesado.TipoDeInmueble = 4; } else if (spnTipoInmueble.SelectedItem.ToString() == "Local") { interesado.TipoDeInmueble = 5; } else if (spnTipoInmueble.SelectedItem.ToString() == "Fondo de Comercio") { interesado.TipoDeInmueble = 6; } else if (spnTipoInmueble.SelectedItem.ToString() == "Oficina") { interesado.TipoDeInmueble = 7; } else if (spnTipoInmueble.SelectedItem.ToString() == "Galpon") { interesado.TipoDeInmueble = 8; } if (spnTipoOperacion.SelectedItem.ToString() == "Venta") { interesado.TipoDeOperacion = 1; } else { interesado.TipoDeOperacion = 2; } if (spnAmbientes.SelectedItem.ToString() == "Monoambiente") { interesado.Ambientes = 1; } else if (spnAmbientes.SelectedItem.ToString() == "Dos Ambiente") { interesado.Ambientes = 2; } else if (spnAmbientes.SelectedItem.ToString() == "Tres Ambientes") { interesado.Ambientes = 3; } else if (spnAmbientes.SelectedItem.ToString() == "Cuatro Ambientes") { interesado.Ambientes = 4; } else if (spnAmbientes.SelectedItem.ToString() == "Cinco o más Ambientes") { interesado.Ambientes = 5; } interesado.MontoDesde = 0m; InmobiliariaService.Service ws = new InmobiliariaService.Service(); ws.GuardarInteresadoAsync(interesado); Toast.MakeText(this, "Se está guardando el interesado!", ToastLength.Long); this.Finish(); }
public GuardarResponse(Interesado interesado) { Error = false; Interesado = interesado; }