/// <summary> /// Registra en la base de datos los datos del Demandante ofrecido por parámetro. /// </summary> /// <param name="dem"></param> /// <returns>Devuelve un booleano según si se ha realizado correctamente o no.</returns> public bool GuardarDatosDemandante(DemandanteModel dem) { Demandante aux = GetDemandanteByUserId(dem.IdUsuario); if (aux != null) { return(false); } dtsDemandantes dts = MappingDemandante.ToDtsDemandantes(dem); Repo.Guardar(dts); Dictionary <DataColumn, Object> parametros = new Dictionary <DataColumn, object>(); parametros.Add(dts.Demandantes.IdUsuarioColumn, dem.IdUsuario); return(Repo.Count(dts.Demandantes, parametros) == 1); }
public bool ModificarDatosUsuario(DemandanteModel demModel) { Demandante aux = GetDemandanteByUserId(demModel.IdUsuario); if (aux == null) { return(false); } dtsUsuarios dts = MappingDemandante.ToDtsUsuarioModificar(demModel); Repo.Guardar(dts); Dictionary <DataColumn, Object> parametros = new Dictionary <DataColumn, object>(); parametros.Add(dts.Usuarios.IdColumn, demModel.IdUsuario); return(true); }
/// <summary> /// Obtiene un objeto Demandante a partir de una id ofrecida por parámetro. /// </summary> /// <param name="id"></param> /// <returns>Devuelve un objeto Demandante</returns> public Demandante GetDemandanteByUserId(int id) { dtsDemandantes dts = new dtsDemandantes(); Dictionary <DataColumn, Object> parametros = new Dictionary <DataColumn, object>(); parametros.Add(dts.Demandantes.IdUsuarioColumn, id); // Realizamos un merge con la tabla vacia del dtsUsuario con los resultados de la tabla obtenida dtsDemandantes.DemandantesDataTable dtDem = (dtsDemandantes.DemandantesDataTable)Repo.Leer(dts.Demandantes, parametros); Demandante dem; if (dtDem.Rows.Count > 0) { dem = MappingDemandante.ToDemandante(dtDem, 0); } else { dem = null; } return(dem); }