Ejemplo n.º 1
0
        /// <summary>
        /// Gets the application user role.
        /// </summary>
        /// <param name="idUserApplication">The id user application.</param>
        /// <param name="idApplication">The id application.</param>
        /// <returns></returns>
        /// <author>Mauricio Suárez Robelto</author>
        /// <company></company>
        /// <date>08/08/2012 02:44 </date>
        private List <ResultRoleDto> GetAuthenticationApplicationUserRole(string ticket, long idCompany, long idApplication, long idUserApplication, long?idApplicationRole)
        {
            List <ResultRoleDto> list = new List <ResultRoleDto>();

            List <ApplicationUserRoleDto> listApplicationUserRoleDto = new List <ApplicationUserRoleDto>();
            ApplicationUserRoleDto        dtoApplicationUserRole     = new ApplicationUserRoleDto();

            dtoApplicationUserRole.IdUserApplication             = idUserApplication;
            dtoApplicationUserRole.IdApplicationRole             = idApplicationRole;
            dtoApplicationUserRole.IdCompany                     = idCompany;
            dtoApplicationUserRole.State                         = true;
            dtoApplicationUserRole.ReferenceTableApplicationRole = true;
            dtoApplicationUserRole.ApplicationRole               = new ApplicationRoleDto()
            {
                ReferenceTableRole       = true,
                ReferenceTableMenuOption = true,
                MenuOption = new List <MenuOptionDto>()
                {
                    new MenuOptionDto()
                    {
                        ReferenceTablePage = true
                    }
                }
            };
            listApplicationUserRoleDto.Add(dtoApplicationUserRole);
            listApplicationUserRoleDto = ApplicationUserRoleRepository.GetApplicationUserRole(listApplicationUserRoleDto).Where(filter => filter.ApplicationRole.IdApplication == idApplication).ToList();

            listApplicationUserRoleDto.ForEach(data =>
            {
                ///rol
                ResultRoleDto dtoResultRole     = new ResultRoleDto();
                dtoResultRole.IdApplicationRole = data.IdApplicationRole;
                dtoResultRole.RoleName          = data.ApplicationRole.Role.RoleName;
                dtoResultRole.RoleDescription   = data.ApplicationRole.Role.RoleDescription;
                dtoResultRole.ImageUrl          = data.ApplicationRole.Role.ImageUrl;

                ///menu rol
                List <ResultMenuOptionDto> listdtoResultMenuOption = new List <ResultMenuOptionDto>();
                data.ApplicationRole.MenuOption.ForEach(dataMenu =>
                {
                    ResultMenuOptionDto dtoResultMenuOption = new ResultMenuOptionDto();
                    dtoResultMenuOption.IdMenuOption        = dataMenu.IdPage;
                    dtoResultMenuOption.IdMenuOptionFather  = dataMenu.IdMenuOptionFather;
                    dtoResultMenuOption.Title    = dataMenu.Page.Title;
                    dtoResultMenuOption.Url      = dataMenu.Page.Url;
                    dtoResultMenuOption.Target   = dataMenu.Target;
                    dtoResultMenuOption.PageLock = dataMenu.PageLock;
                    dtoResultMenuOption.IsMenu   = dataMenu.IsMenu;
                    listdtoResultMenuOption.Add(dtoResultMenuOption);
                });
                dtoResultRole.ListMenu = listdtoResultMenuOption;

                list.Add(dtoResultRole);
            });

            return(list);
        }
Ejemplo n.º 2
0
        private ResultMenuOptionDto RoleMenuSearchSon(ResultMenuOptionDto newMenuOption, List <ResultMenuOptionDto> listMenuOption)
        {
            if (newMenuOption != null)
            {
                List <ResultMenuOptionDto> listSon = new List <ResultMenuOptionDto>();
                listSon.AddRange(listMenuOption.Where(filter => filter.IdMenuOptionFather == newMenuOption.IdMenuOption));
                newMenuOption.Children = listSon;
                if (newMenuOption.Children.Count > 0)
                {
                    foreach (ResultMenuOptionDto data in newMenuOption.Children)
                    {
                        listMenuOption.Where(datafilter => datafilter.IdMenuOption == data.IdMenuOption).FirstOrDefault().IsMenu = true;
                        this.RoleMenuSearchSon(data, listMenuOption.Where(filter => filter.IsMenu == null).ToList());
                    }
                }

                return(newMenuOption);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public List <ResultRoleDto> GetApplicationUserRole(string ticket, long idCompany, long idApplication, long idUserApplication)
        {
            //Get all roles
            List <ResultRoleDto>          listResultRoleDto       = new List <ResultRoleDto>();
            List <ApplicationUserRoleDto> listApplicationUserRole = new List <ApplicationUserRoleDto>();
            List <ApplicationRoleDto>     listApplicationRoleDto  = ApplicationRoleRepository.GetApplicationRole(new ApplicationRoleDto()
            {
                IdApplication = idApplication
            });

            listApplicationRoleDto.ForEach(data =>
            {
                listApplicationUserRole.Add(
                    new ApplicationUserRoleDto()
                {
                    IdCompany                     = idCompany,
                    IdApplicationRole             = data.IdApplicationRole,
                    IdUserApplication             = idUserApplication,
                    State                         = true,
                    ReferenceTableApplicationRole = true,
                    ApplicationRole               = new ApplicationRoleDto()
                    {
                        ReferenceTableRole       = true,
                        ReferenceTableMenuOption = true,
                        MenuOption = new List <MenuOptionDto>()
                        {
                            new MenuOptionDto()
                            {
                                ReferenceTablePage = true
                            }
                        }
                    }
                });
            });

            listApplicationUserRole = ApplicationUserRoleRepository.GetApplicationUserRole(listApplicationUserRole);

            listApplicationUserRole.ForEach(data =>
            {
                ///rol
                ResultRoleDto dtoResultRole     = new ResultRoleDto();
                dtoResultRole.IdApplicationRole = data.IdApplicationRole;
                dtoResultRole.RoleName          = data.ApplicationRole.Role.RoleName;
                dtoResultRole.RoleDescription   = data.ApplicationRole.Role.RoleDescription;
                dtoResultRole.ImageUrl          = data.ApplicationRole.Role.ImageUrl;

                ///menu rol
                List <ResultMenuOptionDto> listdtoResultMenuOption = new List <ResultMenuOptionDto>();
                data.ApplicationRole.MenuOption.ForEach(dataMenu =>
                {
                    ResultMenuOptionDto dtoResultMenuOption = new ResultMenuOptionDto();
                    dtoResultMenuOption.IdMenuOption        = dataMenu.IdPage;
                    dtoResultMenuOption.IdMenuOptionFather  = dataMenu.IdMenuOptionFather;
                    dtoResultMenuOption.Title    = dataMenu.Page.Title;
                    dtoResultMenuOption.Url      = dataMenu.Page.Url;
                    dtoResultMenuOption.Target   = dataMenu.Target;
                    dtoResultMenuOption.PageLock = dataMenu.PageLock;
                    dtoResultMenuOption.IsMenu   = dataMenu.IsMenu;
                    listdtoResultMenuOption.Add(dtoResultMenuOption);
                });
                dtoResultRole.ListMenu = listdtoResultMenuOption;

                listResultRoleDto.Add(dtoResultRole);
            });

            return(listResultRoleDto);
        }