public ResponseAdminRoleApplicationList getRoleApplicationList(RequestAdminRoleApplication req, string id)
        {
            ResponseAdminRoleApplicationList response = new ResponseAdminRoleApplicationList();

            try
            {
                // Primero obtener el listado de Roles
                RequestAdminRole      reqRole   = new RequestAdminRole();
                ResponseAdminRoleList resRole   = new ResponseAdminRoleList();
                LogicAdminRole        logicRole = new LogicAdminRole();

                // Obtener el listado completo de Roles
                reqRole.id = 0;
                resRole    = logicRole.getRoleList(reqRole);

                // Si no se manda un Rol, obtener los permisos del primero
                if (id == null)
                {
                    req.idRole = resRole.lst[0].id;
                }
                else
                {
                    req.idRole = int.Parse(id);
                }

                // Obtener el listado completo de opciones
                RequestAdminApplication      reqApp   = new RequestAdminApplication();
                ResponseAdminApplicationList resApp   = new ResponseAdminApplicationList();
                LogicAdminApplication        logicApp = new LogicAdminApplication();

                reqApp.id = 0;
                resApp    = logicApp.getApplicationList(reqApp);

                LogicCommon com  = new LogicCommon();
                string      json = com.HttpPost("RoleApplication/getAdminRoleApplication", req);
                response = JsonConvert.DeserializeObject <ResponseAdminRoleApplicationList>(json);
                List <SelectListItem> lst = new List <SelectListItem>();

                // Llenar el listado de Roles
                foreach (ResponseAdminRoleDetail r in resRole.lst)
                {
                    lst.Add(new SelectListItem
                    {
                        Text     = r.detail,
                        Value    = r.id.ToString(),
                        Selected = r.id == req.idRole ? true : false
                    });
                }

                // Agregar el listado de Roles
                response.lstRole = lst;
                // Agregar el listado de aplicaciones
                response.lstApplication = resApp.lst;

                return(response);
            }
            catch (Exception ex)
            {
                response.code    = -1;
                response.message = ex.Message;
            }

            return(response);
        }
Example #2
0
        public ResponseAdminUserList getUserList(RequestAdminUser req)
        {
            ResponseAdminUserList response = new ResponseAdminUserList();

            try
            {
                LogicCommon com  = new LogicCommon();
                string      json = com.HttpPost("User/getAdminUser", req);
                response = JsonConvert.DeserializeObject <ResponseAdminUserList>(json);

                // Cargar el listado completo de Roles
                RequestAdminRole      reqRole    = new RequestAdminRole();
                ResponseAdminRoleList resRole    = new ResponseAdminRoleList();
                LogicAdminRole        logicRole  = new LogicAdminRole();
                List <SelectListItem> lstTmpRole = new List <SelectListItem>();

                // Obtener el listado completo de Roles
                reqRole.id = 0;
                resRole    = logicRole.getRoleList(reqRole);

                // Llenar el listado de Roles
                foreach (ResponseAdminRoleDetail r in resRole.lst)
                {
                    lstTmpRole.Add(new SelectListItem
                    {
                        Text     = r.detail,
                        Value    = r.id.ToString(),
                        Selected = r.id == req.idRole ? true : false
                    });
                }

                // Agregar el listado de Roles
                response.lstRole = lstTmpRole;

                // Cargar el catálogo de tipos de documentos
                RequestAdminClsMaster      reqCls    = new RequestAdminClsMaster();
                ResponseAdminClsMasterList resCls    = new ResponseAdminClsMasterList();
                LogicAdminClsMaster        logicCls  = new LogicAdminClsMaster();
                List <SelectListItem>      lstTmpCls = new List <SelectListItem>();

                // Obtener el catálogo de tipos de documentos
                reqCls.catalogId = "TIPOSDOCUMENTO";
                reqCls.child     = true;
                resCls           = logicCls.getClsMasterList(reqCls);

                // Llenar el listado de acuerdo al catálogo
                foreach (ResponseAdminClsMasterDetail r in resCls.lst)
                {
                    lstTmpCls.Add(new SelectListItem
                    {
                        Text     = r.detail,
                        Value    = r.id.ToString(),
                        Selected = r.id == req.typeDocument ? true : false
                    });
                }

                // Agregar el listado del catálogo documentos
                response.lstTypeDocument = lstTmpCls;


                return(response);
            }
            catch (Exception ex)
            {
                response.code    = -1;
                response.message = ex.Message;
            }

            return(response);
        }