Example #1
0
        protected ControllerTests()
        {
            var mockPrincipal = new Mock <IBusinessLogicPrincipal>();

            mockPrincipal.Setup(x => x.IsAllowed).Returns(true);
            mockPrincipal.Setup(x => x.IsAdmin).Returns(true);
            mockPrincipal.Setup(x => x.IsVerwalter).Returns(false);
            mockPrincipal.Setup(x => x.CurrentUid).Returns("if15b032");
            var abl  = new AccessoryBusinessLogic(Dal, mockPrincipal.Object);
            var cbl  = new CustomFieldsBusinessLogic(Dal, mockPrincipal.Object);
            var dbl  = new DamageBusinessLogic(Dal, mockPrincipal.Object);
            var debl = new DeviceBusinessLogic(Dal, mockPrincipal.Object);
            var blbl = new BusinessLogic.BusinessLogic(Dal, mockPrincipal.Object);
            var obl  = new OrderBusinessLogic(Dal, mockPrincipal.Object);
            var sbl  = new SettingBusinessLogic(Dal, mockPrincipal.Object);
            var ubl  = new UserBusinessLogic(Dal, mockPrincipal.Object);

            Bl = new BusinessLogicFacade(Dal, blbl, abl, cbl, dbl, debl, obl, sbl, ubl);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            var subject = new ClaimsIdentity("Federation", ClaimTypes.Name, ClaimTypes.Role);

            subject.AddClaim(new Claim(ClaimTypes.Role, "Admin", ClaimValueTypes.String));
            subject.AddClaim(new Claim(ClaimTypes.Name, "if15b032", ClaimValueTypes.String));
            _controllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext
                {
                    User = new ClaimsPrincipal(subject)
                }
            };
        }
Example #2
0
 private Task OnAuthenticated(FacebookAuthenticatedContext facebookAuthenticatedContext)
 {
     var settingBusinessLogic = new SettingBusinessLogic(new SystemSettingRepository(new DatabaseFactory()));
     settingBusinessLogic.Add(new SystemSetting
     {
         Key = SettingKeyEnum.AccessToken.ToString(),
         Value = facebookAuthenticatedContext.AccessToken
     });
     return Task.FromResult(0);
 }
Example #3
0
 public static void Authorize()
 {
     var fb = new FacebookClient();
     var appId = ConfigurationManager.AppSettings["AppId"];
     var appSecret = ConfigurationManager.AppSettings["AppSecret"];
     dynamic result = fb.Get("oauth/access_token", new
     {
         client_id = appId,
         client_secret = appSecret,
         grant_type = "client_credentials"
     });
     fb.AccessToken = result.access_token;
     var settingBusinessLogic = new SettingBusinessLogic(new SystemSettingRepository(new DatabaseFactory()));
     settingBusinessLogic.Add(new SystemSetting
     {
         Key = SettingKeyEnum.AccessToken.ToString(),
         Value = fb.AccessToken
     });
 }
Example #4
0
 public static FbFeeds GetInfoSocialNetwork()
 {
     try
     {
         var settingBusinessLogic = new SettingBusinessLogic(new SystemSettingRepository(new DatabaseFactory()));
         var groupId = ConfigurationManager.AppSettings["GroupId"];
         var filter = ConfigurationManager.AppSettings["FacebookFilter"];
         var accessToken = settingBusinessLogic.GetByKey(SettingKeyEnum.AccessToken.ToString());
         var cl = new FacebookClient(accessToken.Value);
         var query = cl.Get(groupId + "/?fields=" + filter);
         var ser = new DataContractJsonSerializer(typeof(FbData));
         using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(query.ToString())))
         {
             FbData parsQuery = (FbData)ser.ReadObject(ms);
             return parsQuery.feed;
         }
     }
     catch (Exception ex)
     {
         throw; // ignored
     }
 }