public ActionResult ConsultarDetallePersona(long codigoPersona) { ActionResult actionResult = null; var manejadorLogEventos = new ManejadorLogEventos(); try { var ofiltro = new RequestConsultaDetallePersonaViewModel { filtro = { CodigoPersona = codigoPersona } }; if (ModelState.IsValid) { var oPersona = new PersonaAgente().ConsultarDetallePersona(ofiltro); if (oPersona != null) { actionResult = Content(JsonConvert.SerializeObject(oPersona)); } } else { var cadena = string.Empty; var objetos = GR.Frameworks.Helper.GetErrorsFromModelState(ref cadena, ModelState); actionResult = Content(Grid.emptyStrJSON(cadena, objetos)); } } catch (Exception ex) { HelperCtrl.GrabarLog(ex, "", PoliticaExcepcion.Win); } finally { manejadorLogEventos.RegistrarTiempoEjecucion("", HelperCtrl.ObtenerAtributosManejadorEventos(ControllerContext.ToString(), MethodBase.GetCurrentMethod().Name, HelperCtrl.ObtenerUsuario())); } return(actionResult); }
public ResponseConsultarDetallePersonaViewModel ConsultarDetallePersona(RequestConsultaDetallePersonaViewModel request) { var resp = new ResponseConsultarDetallePersonaViewModel(); try { var requestConsulta = new RequestConsultaDetallePersona { CodigoPersona = request.filtro.CodigoPersona }; var response = new TransmisionesProxyrest().ConsultarDetallePersona(requestConsulta); resp.Result = response.Result; if (response.ListaDetallePersona.Count > 0) { var datos = new DetallePersonaViewModel(); datos.CodigoPersona = response.ListaDetallePersona[0].CodigoPersona; datos.CodigoTipoDocumento = response.ListaDetallePersona[0].CodigoTipoDocumento; datos.CodigoPais = response.ListaDetallePersona[0].CodigoPais; datos.NombrePais = response.ListaDetallePersona[0].NombrePais; datos.RazonSocialPersona = response.ListaDetallePersona[0].RazonSocialPersona; datos.NumeroDocumentoPersona = response.ListaDetallePersona[0].NumeroDocumentoPersona; datos.DireccionPersona = response.ListaDetallePersona[0].DireccionPersona; datos.TelefonoPersona = response.ListaDetallePersona[0].TelefonoPersona; datos.NombreTipoDocumento = response.ListaDetallePersona[0].NombreTipoDocumento; datos.EmailPersona = response.ListaDetallePersona[0].EmailPersona; datos.ContactoPersona = response.ListaDetallePersona[0].ContactoPersona; datos.WebPersona = response.ListaDetallePersona[0].WebPersona; datos.UsuarioCreacion = response.ListaDetallePersona[0].UsuarioCreacion; datos.FechaHoraCreacion = string.Format("{0:dd/MM/yyyy}", response.ListaDetallePersona[0].FechaHoraCreacion); datos.UsuarioActualizacion = response.ListaDetallePersona[0].UsuarioActualizacion; datos.FechaHoraActualizacion = string.Format("{0:dd/MM/yyyy}", response.ListaDetallePersona[0].FechaHoraActualizacion); datos.EstadoRegistro = response.ListaDetallePersona[0].EstadoRegistro; datos.Accion = "U"; #region Sucursales List <long> LstMatchCodigoRoles = new List <long>(); var LstRoles = new MaestrosAgente().ListarRol().ListaRoles; var responseListarRol = new MaestrosAgente().ListarRol(); var UnvRoles = (from item in responseListarRol.ListaRoles select HelperCtrl.MiMapper <ListaRolDTO, ListaRolViewModel>(item)).ToList(); foreach (var x in response.ListaDetallePersona[0].ListaPersonaRol) { var rol = new PersonaRolViewModel { CodigoPersona = x.CodigoPersona, CodigoRol = x.CodigoRol, NombreRol = x.NombreRol, CodigoAduanaPersonaRol = x.CodigoAduanaPersonaRol, Accion = x.Accion }; datos.ListaPersonaRol.Add(rol); LstMatchCodigoRoles.Add(x.CodigoRol); } LstRoles.ForEach(s => { LstMatchCodigoRoles.Add(s.CodigoRol); }); var ListaRol1 = LstMatchCodigoRoles.Distinct().ToList(); foreach (var item in ListaRol1) { var obj = UnvRoles.Where(x => x.CodigoRol == item).ToList(); if (obj.Count > 0) { datos.ListaRol.Add(obj[0]); } } #endregion resp.ListaDetallePersona.Add(datos); } } catch (Exception ex) { ManejadorExcepciones.PublicarExcepcion(ex, PoliticaExcepcion.AgenteServicios); } return(resp); }