예제 #1
0
        public RegisterController()
        {
            userBusinessContext = new UserBusinessContext();
            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <UserRegistrationViewModel, UserDTO>();
            });
            var RoleBasicDTOMapRoleViewConfig = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <RoleBasicDTO, UserRegistrationViewModel>();
            });

            RegistrationMapper            = new Mapper(config);
            RoleBasicDTOMapRoleViewMapper = new Mapper(RoleBasicDTOMapRoleViewConfig);
            roleBasicDTOList = userBusinessContext.GetRoles();
        }
예제 #2
0
        public RoleBasicDTO GetRole()
        {
            List <Role> roles = shoppingCartEntities.Roles.Where(p => p.Name != "ADMIN").ToList();

            Debug.WriteLine(shoppingCartEntities.Roles.Where(p => p.Name != "ADMIN").ToList());
            IEnumerable <Role> convertRoles = roles.AsEnumerable <Role>();
            RoleBasicDTO       roleBasicDTO = new RoleBasicDTO();

            roleBasicDTO.roles = roleMapRoleBasicDTOMapper.Map <IEnumerable <Role>, IEnumerable <RoleDTO> >(convertRoles);
            if (roles != null)
            {
                return(roleBasicDTO);
            }
            else
            {
                throw new NotFoundException();
            }
        }
예제 #3
0
        public RoleBasicDTO GetRoles()
        {
            RoleBasicDTO roleBasicDTO = userDatabase.GetRole();

            try
            {
                if (userDatabase.GetRole().roles.Count() <= 0)
                {
                    throw new NoRolesFoundException();
                }
                else
                {
                    return(roleBasicDTO);
                }
            }
            catch (NoRolesFoundException ex)
            {
                throw new NoRolesFoundException();
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }