public Model.TurnoModel GetTurnoByID(Model.TurnoModel turno)
        {
            Model.TurnoModel t = new Model.TurnoModel();

            using (var entity = new GestorDocumentEntities())
            {
                GET_TURNO result = null;
                try
                {
                    result = (from o in entity.GET_TURNO
                              where o.IsActive == true && o.IdAsunto == turno.IdAsunto
                              select o).First();
                }
                catch (Exception)
                {
                    ;
                }
                if (result != null)
                {
                    t.IdTurno = result.IdTurno;
                    t.IdTurnoAnt = result.IdTurnoAnt;
                    t.FechaCreacion = result.FechaCreacion;
                    t.FechaEnvio = result.FechaEnvio;
                    t.IsActive = result.IsActive;
                    t.LastModifiedDate = result.LastModifiedDate;
                    t.IsModified = result.IsModified;
                    t.IdAsunto = result.IdAsunto;
                    t.Asunto = new Model.AsuntoModel()
                    {
                        IdAsunto = result.IdAsunto,
                        FechaCreacion = result.GET_ASUNTO.FechaCreacion,
                        FechaRecibido = result.GET_ASUNTO.FechaRecibido,
                        FechaDocumento = result.GET_ASUNTO.FechaDocumento,
                        Titulo = result.GET_ASUNTO.Titulo,
                        Descripcion = result.GET_ASUNTO.Descripcion,
                        Alcance = result.GET_ASUNTO.Alcance,
                        IdUbicacion = result.GET_ASUNTO.IdUbicacion,
                        ReferenciaDocumento = result.GET_ASUNTO.ReferenciaDocumento,
                        Ubicacion = (result.GET_ASUNTO.CAT_UBICACION != null) ? new Model.UbicacionModel()
                        {
                            UbicacionName = result.GET_ASUNTO.CAT_UBICACION.UbicacionName
                        } :null,
                        IdInstruccion = result.GET_ASUNTO.IdInstruccion,
                        Instruccion =(result.GET_ASUNTO.CAT_INSTRUCCION != null) ? new Model.InstruccionModel()
                        {
                            InstruccionName = result.GET_ASUNTO.CAT_INSTRUCCION.InstruccionName
                        }:null,
                        IdPrioridad = result.GET_ASUNTO.IdPrioridad,
                        Prioridad = new Model.PrioridadModel()
                        {
                            PrioridadName = result.GET_ASUNTO.CAT_PRIORIDAD.PrioridadName
                            ,
                            IdPrioridad = result.GET_ASUNTO.CAT_PRIORIDAD.IdPrioridad
                            ,
                            PathImagen = result.GET_ASUNTO.CAT_PRIORIDAD.PathImagen
                        },
                        IdStatusAsunto = result.GET_ASUNTO.IdStatusAsunto,
                        StatusAsunto = new Model.StatusAsuntoModel()
                        {
                            StatusName = result.GET_ASUNTO.CAT_STATUS_ASUNTO.StatusName
                        },
                        FechaVencimiento = result.GET_ASUNTO.FechaVencimiento,
                        Folio = result.GET_ASUNTO.Folio,
                        UbicacionText = result.GET_ASUNTO.Ubicacion,
                        IsBorrador = result.GET_ASUNTO.IsBorrador

                    };
                    t.IdStatusTurno = result.IdStatusTurno;
                    t.IdRol = result.IdRol;
                    t.IdUsuario = result.IdUsuario;
                    t.Comentario = result.Comentario;
                    t.Respuesta = result.Respuesta;
                    t.ServerLastModifiedDate = result.ServerLastModifiedDate;
                    t.IsTurnado = result.IsTurnado;
                    t.IsAtendido = result.IsAtendido;
                    t.IsBorrador = result.IsBorrador;
                    t.Rol = new Model.RolModel()
                    {
                        IdRol = result.APP_ROL.IdRol
                        ,
                        RolName = result.APP_ROL.RolName
                    };
                }
            }
            return t;
        }
        public Model.TurnoModel GetTurnoID()
        {
            Model.TurnoModel turno = new Model.TurnoModel();

            using (var entity = new GestorDocumentEntities())
            {
                GET_TURNO result = null;
                try
                {
                    result = (from o in entity.GET_TURNO
                              where o.IdTurnoAnt == null && o.IsActive == true
                              select o).First();
                }
                catch (Exception)
                {
                    ;
                }
                if (result != null)
                {
                    turno.IdTurno = result.IdTurno;
                    turno.IdTurnoAnt = result.IdTurnoAnt;
                    turno.FechaCreacion = result.FechaCreacion;
                    turno.FechaEnvio = result.FechaEnvio;
                    turno.IsActive = result.IsActive;
                    turno.LastModifiedDate = result.LastModifiedDate;
                    turno.IsModified = result.IsModified;
                    turno.IdAsunto = result.IdAsunto;
                    turno.IdStatusTurno = result.IdStatusTurno;
                    turno.IdRol = result.IdRol;
                    turno.IdUsuario = result.IdUsuario;
                    turno.Comentario = result.Comentario;
                    turno.Respuesta = result.Respuesta;
                    turno.ServerLastModifiedDate = result.ServerLastModifiedDate;
                    turno.IsTurnado = result.IsTurnado;
                    turno.IsAtendido = result.IsAtendido;
                    turno.IsBorrador = result.IsBorrador;
                    turno.Rol = new Model.RolModel()
                    {
                        IdRol = result.APP_ROL.IdRol
                        ,
                        RolName=result.APP_ROL.RolName
                    };
                }
            }
            return turno;
        }