public RetornaMensaje EliminarVivienda(string codVivienda) { ViviendaBE vivienda = new ViviendaBE(); try { retornaMensaje = new RetornaMensaje(); viviendaDAO = new ViviendaDAO(); retornaMensaje.Exito = viviendaDAO.Eliminar(Convert.ToInt32(codVivienda)); if( retornaMensaje.Exito ) retornaMensaje = new RetornaMensaje { Mensage = string.Format(resMensajes.msjEliminadoOK, "Vivienda"), CodigoError = "-1", Exito = false }; } catch (Exception exception) { RetornaMensaje mensajeError = new RetornaMensaje { Mensage = string.Format(resMensajes.msjNoEliminado, "Vivienda"), CodigoError = exception.GetHashCode().ToString(), Exito = false }; throw new WebFaultException<RetornaMensaje>(mensajeError, HttpStatusCode.InternalServerError); } return retornaMensaje; }
public RetornaMensaje CrearVivienda(ViviendaBE viviendaCrear) { //List<ViviendaBE> lstViviendaBuscar = null; try { retornaMensaje = new RetornaMensaje(); viviendaDAO = new ViviendaDAO(); //lstViviendaBuscar = viviendaDAO.Buscar(viviendaCrear); //if (lstViviendaBuscar.Count == 0) //{ retornaMensaje.CodigoRetorno = viviendaDAO.Registrar(viviendaCrear); retornaMensaje.Mensage = string.Format(resMensajes.msjGuardadoOK, "Vivienda"); retornaMensaje.Exito = true; //} //else //{ // RetornaMensaje mensajeError = new RetornaMensaje // { // CodigoRetorno = -1, // Mensage = string.Format(resMensajes.msjYaExiste, "Vivienda"), // Exito = false, // }; // throw new WebFaultException<RetornaMensaje>(mensajeError, HttpStatusCode.InternalServerError); //} } catch (Exception exception) { RetornaMensaje mensajeError = new RetornaMensaje { Mensage = string.Format(resMensajes.msjNoRegistrado + " - " + exception.Message, "Vivienda"), CodigoError = exception.GetHashCode().ToString(), Exito = false }; throw new WebFaultException<RetornaMensaje>(mensajeError, HttpStatusCode.InternalServerError); } return retornaMensaje; }
public List<ViviendaBE> ListarVivienda() { List<ViviendaBE> lstCuota = new List<ViviendaBE>(); try { viviendaDAO = new ViviendaDAO(); lstCuota = viviendaDAO.Listar(null, null); } catch (Exception exception) { throw new FaultException<RetornaMensaje> (new RetornaMensaje { Mensage = string.Format(resMensajes.msjNoListado, "Vivienda"), CodigoError = exception.GetHashCode().ToString(), Exito = true } , new FaultReason(exception.Message)); } return lstCuota; }
public ViviendaBE ObtenerVivienda(string codVivienda) { ViviendaBE vivienda = new ViviendaBE(); try { retornaMensaje = new RetornaMensaje(); viviendaDAO = new ViviendaDAO(); vivienda = viviendaDAO.Buscar(Convert.ToInt32(codVivienda)); } catch (Exception exception) { RetornaMensaje mensajeError = new RetornaMensaje { Mensage = string.Format(resMensajes.msjNoBuscado, "Vivienda"), CodigoError = exception.GetHashCode().ToString(), Exito = false }; throw new WebFaultException<RetornaMensaje>(mensajeError, HttpStatusCode.InternalServerError); } return vivienda; }