Beispiel #1
0
        private static async Task <bool> UpdateClaims(ApplicationUser user, UserManager <ApplicationUser> userManager, System.Collections.Generic.IList <Claim> claims, string type, string value)
        {
            var shouldUpdate = false;

            if (claims.Any(x => x.Type == type && x.Value != value) ||
                !claims.Any(x => x.Type == type))
            {
                await userManager.RemoveClaimsAsync(user, claims.Where(x => x.Type == type));

                await userManager.AddClaimAsync(user, new Claim(type, value));

                shouldUpdate = true;
            }

            return(shouldUpdate);
        }
Beispiel #2
0
            public void Should_return_false_if_one_of_the_rules_fail()
            {
                // Act
                var result = queryBuilder.BuildRulesPredicate(new List <QueryRule>
                {
                    new QueryRule("Number", FieldOperation.Equal, "7"),
                    new QueryRule("Text", FieldOperation.Contains, "ere")
                });

                var filteredData = _testData.Where(x => result(x));

                // Assert
                Assert.Equal(0, filteredData.Count());
            }
Beispiel #3
0
 private void GetDefaultData(System.Web.HttpContext context)
 {
     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
     stringBuilder.Append("{\"result\":{\"advs\":[");
     System.Collections.Generic.IList <BannerInfo> allBanners = VShopHelper.GetAllBanners(ClientType.App);
     if (allBanners != null && allBanners.Count > 0)
     {
         allBanners = allBanners.Where(m => m.LocationType != LocationType.Register).ToList();
         if (allBanners != null && allBanners.Count > 0)
         {
             foreach (BannerInfo current in allBanners)
             {
                 stringBuilder.Append("{");
                 stringBuilder.AppendFormat("\"pic\":\"{0}\",", Globals.FullPath(current.ImageUrl));
                 stringBuilder.AppendFormat("\"description\":\"{0}\",", current.ShortDesc);
                 if (!string.IsNullOrEmpty(current.LoctionUrl))
                 {
                     stringBuilder.AppendFormat("\"url\":\"{0}\"", current.LoctionUrl);
                 }
                 else
                 {
                     stringBuilder.AppendFormat("\"url\":\"{0}\"", "javascript:;");
                 }
                 stringBuilder.Append("},");
             }
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("],");
     stringBuilder.Append("\"navigates\":[");
     System.Collections.Generic.IList <NavigateInfo> allNavigate = VShopHelper.GetAllNavigate(ClientType.App);
     if (allNavigate != null && allNavigate.Count > 0)
     {
         foreach (NavigateInfo current2 in allNavigate)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"pic\":\"{0}\",", Globals.FullPath(current2.ImageUrl));
             stringBuilder.AppendFormat("\"description\":\"{0}\",", current2.ShortDesc);
             if (!string.IsNullOrEmpty(current2.LoctionUrl))
             {
                 stringBuilder.AppendFormat("\"url\":\"{0}\"", current2.LoctionUrl);
             }
             else
             {
                 stringBuilder.AppendFormat("\"url\":\"{0}\"", "javascript:;");
             }
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("],");
     stringBuilder.Append("\"topics\":[");
     System.Data.DataTable homeTopics = VShopHelper.GetHomeTopics(ClientType.App);
     if (homeTopics != null && homeTopics.Rows.Count > 0)
     {
         foreach (System.Data.DataRow dataRow in homeTopics.Rows)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"tid\":{0},", dataRow["TopicId"]);
             stringBuilder.AppendFormat("\"title\":\"{0}\",", dataRow["title"]);
             stringBuilder.AppendFormat("\"pic\":\"{0}\",", Globals.FullPath((string)dataRow["IconUrl"]));
             stringBuilder.AppendFormat("\"url\":\"{0}\"", Globals.FullPath(string.Format("/AppShop/Topics.aspx?TopicId={0}", dataRow["TopicId"])));
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("],");
     stringBuilder.Append("\"tagProducts\":[");
     System.Data.DataTable homeProducts = VShopHelper.GetHomeProducts(ClientType.App);
     if (homeProducts != null && homeProducts.Rows.Count > 0)
     {
         foreach (System.Data.DataRow dataRow2 in homeProducts.Rows)
         {
             stringBuilder.Append("{");
             stringBuilder.AppendFormat("\"pid\":{0},", dataRow2["ProductId"]);
             stringBuilder.AppendFormat("\"name\":\"{0}\",", dataRow2["ProductName"].ToString().Replace("\\", "").Replace("\\", ""));
             stringBuilder.AppendFormat("\"pic\":\"{0}\",", (dataRow2["ThumbnailUrl180"] != System.DBNull.Value) ? Globals.FullPath((string)dataRow2["ThumbnailUrl180"]) : Globals.FullPath(this.siteSettings.DefaultProductThumbnail5));
             stringBuilder.AppendFormat("\"price\":\"{0}\",", ((decimal)dataRow2["SalePrice"]).ToString("F2"));
             stringBuilder.AppendFormat("\"saleCounts\":\"{0}\",", ((int)dataRow2["ShowSaleCounts"]).ToString());
             stringBuilder.AppendFormat("\"url\":\"{0}\"", Globals.FullPath(string.Format("/AppShop/ProductDetails.aspx?productId={0}", dataRow2["ProductId"])));
             stringBuilder.Append("},");
         }
         stringBuilder.Remove(stringBuilder.Length - 1, 1);
     }
     stringBuilder.Append("]}}");
     context.Response.Write(stringBuilder.ToString());
 }