Esempio n. 1
0
        public static T GetService <T>(RequestContext Request) where T : class
        {
            string Token       = string.Empty;
            var    SessionAuth = Request.HttpContext.Session[GlobalParams.UserSessionKey];
            var    TokenType   = SVC.DTO.TokenType.WebAuth;

            if (SessionAuth != null)
            {
                var AuthObject = (AuthResponse)SessionAuth;
                Token = AuthObject.Token;
            }

            if (typeof(T) == typeof(IAuthService))
            {
                return((T)ServiceFinder.GetAuthService());
            }
            else if (typeof(T) == typeof(IContentService))
            {
                return((T)ServiceFinder.GetContentService(Token, TokenType, Request.HttpContext.Server.MapPath("~/Uploads/")));
            }
            else if (typeof(T) == typeof(IUserService))
            {
                return((T)ServiceFinder.GetUserService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGroupService))
            {
                return((T)ServiceFinder.GetGroupService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGenreService))
            {
                return((T)ServiceFinder.GetGenreService(Token, TokenType));
            }

            return(null);
        }
Esempio n. 2
0
 public void SetUp()
 {
     tokenType = TokenType.WebAuth;
     cdDb      = new CDSEntities();
     using (var TokenService = ServiceFinder.GetTokenService())
     {
         tokenCode = TokenService.CreateToken(tokenType, 1);
     }
     genreService = ServiceFinder.GetGenreService(tokenCode, tokenType);
     testName     = "TESTENAME";
 }