public static ProductDescriptionConfig IsExcistProductDescriptionItem(ProductDescriptionModel item, ProductDescriptionConfig data)
        {
            ProductDescriptionConfig configDetails = new ProductDescriptionConfig();
            ProductDescriptionBrand  brandItem     = new ProductDescriptionBrand();

            if (item.AddOrDel > 0 && data.AddOrDel == 0)
            {
                data.AddOrDel = item.AddOrDel;
            }

            if (!string.IsNullOrEmpty(item.CategoryName) && string.IsNullOrEmpty(item.Brand) && !data.Categories.Contains(item.CategoryName))
            {
                data.Categories.Add(item.CategoryName);
            }

            if (!string.IsNullOrEmpty(item.PID) && !data.Pids.Contains(item.PID))
            {
                data.Pids.Add(item.PID);
            }

            if (!string.IsNullOrEmpty(item.Brand))
            {
                if (data.BrandDetails.Where(o => o.BrandCategoryName.Equals(item.CategoryName)).Count() > 0)
                {
                    foreach (var configItem in data.BrandDetails)
                    {
                        if (String.Equals(configItem.BrandCategoryName, item.CategoryName))
                        {
                            if (String.Equals(configItem.BrandCategoryName, item.CategoryName) && !configItem.Brands.Contains(item.Brand))
                            {
                                configItem.Brands.Add(item.Brand);
                            }
                        }
                    }
                }
                else
                {
                    brandItem.Brands = new List <string>();

                    brandItem.BrandCategoryName = item.CategoryName;
                    brandItem.Brands.Add(item.Brand);
                    data.BrandDetails.Add(brandItem);
                }
            }

            return(data);
        }
        public static List <ProductDescriptionViewModel> ConvertToList(List <ProductDescriptionModel> models)
        {
            List <ProductDescriptionViewModel> result = new List <ProductDescriptionViewModel>();
            var source = PromotionManager.SelectProductCategoryCategoryNameAndDisplayName().ToList();

            if (models != null && models.Count() > 0)
            {
                foreach (var item in models)
                {
                    ProductDescriptionViewModel viewModel     = new ProductDescriptionViewModel();
                    ProductDescriptionConfig    configDetails = new ProductDescriptionConfig();
                    ProductDescriptionBrand     brandItem     = new ProductDescriptionBrand();
                    configDetails.Categories   = new List <string>();
                    configDetails.Pids         = new List <string>();
                    configDetails.BrandDetails = new List <ProductDescriptionBrand>();
                    brandItem.Brands           = new List <string>();

                    if (result.Where(o => o.ModuleID.Equals(item.ModuleID)).Count() > 0)
                    {
                        foreach (var configItem in result)
                        {
                            if (configItem.ModuleID.Equals(item.ModuleID))
                            {
                                configItem.ProductConfigDetails = IsExcistProductDescriptionItem(item, configItem.ProductConfigDetails);

                                if (item.IsAdvert)
                                {
                                    if (configItem.ModuleID.Equals(item.ModuleID) && configItem.PlatfromType != item.ShowPlatform)
                                    {
                                        switch (item.ShowPlatform)
                                        {
                                        case 1:
                                            configItem.PCUrl = item.URL;
                                            break;

                                        case 3:
                                            configItem.IOSHandleKey  = item.AppHandleKey;
                                            configItem.IOSSpecialKey = item.AppSpecialKey;
                                            break;

                                        case 4:
                                            configItem.AndroidHandleKey  = item.AppHandleKey;
                                            configItem.AndroidSpecialKey = item.AppSpecialKey;
                                            break;

                                        case 5:
                                            configItem.H5Url = item.URL;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        viewModel.ModuleID      = item.ModuleID;
                        viewModel.ModuleName    = item.ModuleName;
                        viewModel.PlatfromType  = item.ShowPlatform;
                        viewModel.ContentHtml   = item.ModuleContent;
                        viewModel.ModuleOrder   = item.ModuleOrder;
                        viewModel.IsAdvertise   = item.IsAdvert;
                        viewModel.StartDateTime = item.StartDateTime;
                        viewModel.EndDateTime   = item.EndDateTime;
                        if (item.IsAdvert)
                        {
                            viewModel.SmallImageUrl = item.SmallImageUrl;
                            viewModel.BigImageUrl   = item.BigImageUrl;

                            switch (item.ShowPlatform)
                            {
                            case 1:
                                viewModel.PCUrl = item.URL;
                                break;

                            case 3:
                                viewModel.IOSHandleKey  = item.AppHandleKey;
                                viewModel.IOSSpecialKey = item.AppSpecialKey;
                                break;

                            case 4:
                                viewModel.AndroidHandleKey  = item.AppHandleKey;
                                viewModel.AndroidSpecialKey = item.AppSpecialKey;
                                break;

                            case 5:
                                viewModel.H5Url = item.URL;
                                break;
                            }
                        }

                        configDetails.AddOrDel = item.AddOrDel;

                        if (!string.IsNullOrEmpty(item.CategoryName) && string.IsNullOrEmpty(item.Brand))
                        {
                            configDetails.Categories.Add(item.CategoryName);
                        }
                        if (!string.IsNullOrEmpty(item.PID))
                        {
                            configDetails.Pids.Add(item.PID);
                        }
                        if (!string.IsNullOrEmpty(item.Brand))
                        {
                            brandItem.BrandCategoryName = item.CategoryName;
                            brandItem.Brands.Add(item.Brand);
                            configDetails.BrandDetails.Add(brandItem);
                        }

                        viewModel.ProductConfigDetails = configDetails;

                        result.Add(viewModel);
                    }
                }
            }

            result = ShowProductCategoryName(result, source);

            return(result);
        }