Exemplo n.º 1
0
        public void EnableHomeFloor(long homeFloorId, bool enable)
        {
            HomeFloorInfo homeFloorInfo = context.HomeFloorInfo.FindById <HomeFloorInfo>(homeFloorId);

            homeFloorInfo.IsShow = enable;
            context.SaveChanges();
        }
Exemplo n.º 2
0
        public HomeFloorInfo AddHomeFloorBasicInfo(string name, IEnumerable <long> topLevelCategoryIds)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("楼层名称不能为空");
            }
            if (topLevelCategoryIds == null || topLevelCategoryIds.Count() == 0)
            {
                throw new ArgumentNullException("至少要选择一个商品分类");
            }
            HomeFloorInfo homeFloorInfo = new HomeFloorInfo()
            {
                FloorName = name
            };

            lock (FloorService.DisplaySequenceLocker)
            {
                homeFloorInfo.DisplaySequence = GetMaxHomeFloorSequence() + 1;
                foreach (long list in topLevelCategoryIds.ToList())
                {
                    FloorCategoryInfo floorCategoryInfo = new FloorCategoryInfo()
                    {
                        CategoryId = list,
                        Depth      = 1
                    };
                    homeFloorInfo.FloorCategoryInfo.Add(floorCategoryInfo);
                }
                context.HomeFloorInfo.Add(homeFloorInfo);
                context.SaveChanges();
            }
            return(homeFloorInfo);
        }
Exemplo n.º 3
0
        public HomeFloorInfo AddHomeFloorBasicInfo(string name, IEnumerable <long> topLevelCategoryIds)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("楼层名称不能为空");
            }
            if (topLevelCategoryIds == null || topLevelCategoryIds.Count() == 0)
            {
                throw new ArgumentNullException("至少要选择一个商品分类");
            }

            var homeFloorInfo = new HomeFloorInfo()
            {
                FloorName = name,
            };

            lock (DisplaySequenceLocker)                                       //防止添加重复的顺序号
            {
                homeFloorInfo.DisplaySequence = GetMaxHomeFloorSequence() + 1; //设置显示序号
                DbFactory.Default.Add(homeFloorInfo);
                var categories = topLevelCategoryIds.Select(item => new FloorCategoryInfo
                {
                    CategoryId = item,
                    Depth      = 1, //基本信息只保存一级分类
                    FloorId    = homeFloorInfo.Id
                });
                DbFactory.Default.Add(categories);
            }
            return(homeFloorInfo);
        }
        public ActionResult AddHomeFloor(long id = 0L)
        {
            HomeFloorInfo homeFloor = ServiceHelper.Create <IFloorService>().GetHomeFloor(id) ?? new HomeFloorInfo();

            ViewBag.TopLevelCategories = ServiceHelper.Create <ICategoryService>().GetCategoryByParentId(0);
            return(View(homeFloor));
        }
Exemplo n.º 5
0
        public HomeFloorInfo AddHomeFloorBasicInfo(string name, IEnumerable <long> topLevelCategoryIds)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("楼层名称不能为空");
            }
            if (topLevelCategoryIds == null || topLevelCategoryIds.Count() == 0)
            {
                throw new ArgumentNullException("至少要选择一个商品分类");
            }

            var homeFloorInfo = new HomeFloorInfo()
            {
                FloorName = name,
            };

            lock (DisplaySequenceLocker)                                       //防止添加重复的顺序号
            {
                homeFloorInfo.DisplaySequence = GetMaxHomeFloorSequence() + 1; //设置显示序号

                foreach (var categoryId in topLevelCategoryIds.ToList())       //添加楼层分类信息
                {
                    var floorCategory = new FloorCategoryInfo()
                    {
                        CategoryId = categoryId,
                        Depth      = 1 //基本信息只保存一级分类
                    };
                    homeFloorInfo.FloorCategoryInfo.Add(floorCategory);
                }

                Context.HomeFloorInfo.Add(homeFloorInfo);
                Context.SaveChanges();
            }
            return(homeFloorInfo);
        }
        public ActionResult AddHomeFloorDetail(long id = 0L)
        {
            string          str;
            string          str1;
            HomeFloorDetail homeFloorDetail = new HomeFloorDetail()
            {
                Id = 0
            };
            HomeFloorInfo homeFloor = ServiceHelper.Create <IFloorService>().GetHomeFloor(id);

            if (homeFloor != null)
            {
                homeFloorDetail.Id        = homeFloor.Id;
                homeFloorDetail.TextLinks =
                    from item in homeFloor.FloorTopicInfo
                    where item.TopicType == Position.Top
                    select new HomeFloorDetail.TextLink()
                {
                    Id   = item.Id,
                    Name = item.TopicName,
                    Url  = item.Url
                };
                homeFloorDetail.ProductLinks =
                    from item in homeFloor.FloorTopicInfo
                    where item.TopicType != Position.Top
                    select new HomeFloorDetail.TextLink()
                {
                    Id   = (long)item.TopicType,
                    Name = item.Url,
                    Url  = item.TopicImage
                } into i
                orderby i.Id
                select i;
            }
            else
            {
                homeFloor = new HomeFloorInfo();
                List <HomeFloorDetail.TextLink> textLinks = new List <HomeFloorDetail.TextLink>();
                for (int num = 0; num < 10; num++)
                {
                    HomeFloorDetail.TextLink textLink = new HomeFloorDetail.TextLink()
                    {
                        Id   = num,
                        Name = "",
                        Url  = ""
                    };
                    textLinks.Add(textLink);
                }
                homeFloorDetail.ProductLinks = textLinks;
            }
            dynamic viewBag = base.ViewBag;

            str = (homeFloor == null ? "" : homeFloor.FloorName);
            viewBag.FloorName = str;
            dynamic obj = base.ViewBag;

            str1        = (homeFloor == null ? "" : homeFloor.SubName);
            obj.SubName = str1;
            return(View(homeFloorDetail));
        }
Exemplo n.º 7
0
        public JsonResult GetBrandsAjax(long id = 0)
        {
            HomeFloorInfo homeFloor = null;
            IEnumerable <HomeFloorDetail.Brand> _Floorbrands = null;
            var brands = _iBrandService.GetBrands("");

            if (id != 0)
            {
                homeFloor    = _iFloorService.GetHomeFloor(id);
                _Floorbrands = homeFloor.FloorBrandInfo.Select(
                    item => new HomeFloorDetail.Brand()
                {
                    Id   = item.BrandId,
                    Name = item.BrandInfo.Name
                }
                    );
            }

            var data = new List <BrandViewModel>();

            foreach (var brand in brands)
            {
                data.Add(new Models.Product.BrandViewModel
                {
                    id        = brand.Id,
                    isChecked = null == _Floorbrands ? false : _Floorbrands.Any(b => b.Id.Equals(brand.Id)),
                    value     = brand.Name
                });
            }
            return(Json(new
            {
                data = data
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public void UpdateHomeFloorSequence(long sourceSequence, long destiSequence)
        {
            HomeFloorInfo homeFloorInfo  = context.HomeFloorInfo.FirstOrDefault((HomeFloorInfo item) => item.DisplaySequence == sourceSequence);
            HomeFloorInfo homeFloorInfo1 = context.HomeFloorInfo.FirstOrDefault((HomeFloorInfo item) => item.DisplaySequence == destiSequence);

            homeFloorInfo.DisplaySequence  = destiSequence;
            homeFloorInfo1.DisplaySequence = sourceSequence;
            context.SaveChanges();
        }
Exemplo n.º 9
0
        public ActionResult AddHomeFloor(long id = 0)
        {
            var homeFloor = _iFloorService.GetHomeFloor(id);

            if (homeFloor == null)
            {
                homeFloor = new HomeFloorInfo();
            }
            ViewBag.TopLevelCategories = _iCategoryService.GetCategoryByParentId(0);
            return(View(homeFloor));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 楼层四
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult AddHomeFloorDetail4(long id = 0)
        {
            var homeFloorDetail = new HomeFloorDetail()
            {
                Id = 0
            };
            var homeFloor = _iFloorService.GetHomeFloor(id);

            if (homeFloor == null)
            {
                homeFloor = new HomeFloorInfo();
                var ProductLinks = new List <HomeFloorDetail.TextLink>();
                for (int i = 0; i < 10; i++)
                {
                    ProductLinks.Add(new HomeFloorDetail.TextLink
                    {
                        Id   = i,
                        Name = "",
                        Url  = ""
                    });
                }
                homeFloorDetail.ProductLinks = ProductLinks;
                homeFloorDetail.StyleLevel   = 3;
            }
            else
            {
                homeFloorDetail.Id = homeFloor.Id;

                //填充文字链接
                homeFloorDetail.TextLinks = homeFloor.FloorTopicInfo.Where(item => item.TopicType == Position.Top).Select(item => new HomeFloorDetail.TextLink()
                {
                    Id   = item.Id,
                    Name = item.TopicName,
                    Url  = item.Url
                });

                homeFloorDetail.ProductLinks = homeFloor.FloorTopicInfo
                                               .Where(item => item.TopicType != Position.Top)
                                               .Select(item => new HomeFloorDetail.TextLink()
                {
                    Id   = (long)item.TopicType,
                    Name = item.Url,
                    Url  = item.TopicImage,
                }).OrderBy(i => i.Id);
            }


            ViewBag.FloorName = homeFloor == null ? "" : homeFloor.FloorName;
            ViewBag.SubName   = homeFloor == null ? "" : homeFloor.SubName;
            return(View(homeFloorDetail));
        }
Exemplo n.º 11
0
        public void UpdateFloorBasicInfo(long homeFloorId, string name, IEnumerable <long> topLevelCategoryIds)
        {
            IEnumerable <long> nums = topLevelCategoryIds;

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("楼层名称不能为空");
            }
            if (nums == null || nums.Count() == 0)
            {
                throw new ArgumentNullException("至少要选择一个商品分类");
            }
            HomeFloorInfo homeFloorInfo = context.HomeFloorInfo.FindById <HomeFloorInfo>(homeFloorId);

            homeFloorInfo.FloorName = name;
            nums = nums.Distinct <long>();
            IEnumerable <long> floorCategoryInfo =
                from item in homeFloorInfo.FloorCategoryInfo
                select item.CategoryId;
            IEnumerable <long> nums1 =
                from item in floorCategoryInfo
                where !nums.Contains(item)
                select item;
            IEnumerable <long> nums2 =
                from item in nums
                where !floorCategoryInfo.Contains(item)
                select item;

            FloorCategoryInfo[] floorCategoryInfoArray = new FloorCategoryInfo[nums2.Count()];
            int num = 0;

            foreach (long list in nums2.ToList())
            {
                int num1 = num;
                num = num1 + 1;
                FloorCategoryInfo floorCategoryInfo1 = new FloorCategoryInfo()
                {
                    FloorId    = homeFloorId,
                    CategoryId = list,
                    Depth      = 1
                };
                floorCategoryInfoArray[num1] = floorCategoryInfo1;
            }
            context.FloorCategoryInfo.OrderBy((FloorCategoryInfo item) => item.FloorId == homeFloorId && nums1.Contains(item.CategoryId));
            context.FloorCategoryInfo.AddRange(floorCategoryInfoArray);
            context.SaveChanges();
        }
Exemplo n.º 12
0
        public void UpdateHomeFloorDetail(HomeFloorInfo homeFloor)
        {
            if (homeFloor.Id == 0)
            {
                long?sequence = 0;
                var  floor    = Context.HomeFloorInfo.Select(p => p.DisplaySequence);
                if (floor.Count() > 0)
                {
                    sequence = floor.Max();
                }
                if (!sequence.HasValue)
                {
                    sequence = 0;
                }
                homeFloor.DisplaySequence = sequence.Value + 1;
                homeFloor.IsShow          = true;
                Context.HomeFloorInfo.Add(homeFloor);
            }
            else
            {
                var f = Context.HomeFloorInfo.FindById(homeFloor.Id);
                f.DefaultTabName = homeFloor.DefaultTabName;
                f.FloorName      = homeFloor.FloorName;
                f.SubName        = homeFloor.SubName;
            }
            //UpdateCategory(homeFloor.Id, homeFloor.FloorCategoryInfo);

            if (homeFloor.StyleLevel == 1 || homeFloor.StyleLevel == 4 || homeFloor.StyleLevel == 5 || homeFloor.StyleLevel == 6 || homeFloor.StyleLevel == 7)
            {
                UpdateProducts(homeFloor.Id, homeFloor.Himall_FloorTabls);
            }


            UpdateBrand(homeFloor.Id, homeFloor.FloorBrandInfo);

            //UpdateCategoryImage(homeFloor.Id, homeFloor.FloorTopicInfo.FirstOrDefault(item => item.TopicType == Position.Top));

            UpdateTextLink(homeFloor.Id, homeFloor.FloorTopicInfo.Where(item => item.TopicType == Position.Top));

            UpdataProductLink(homeFloor.Id, homeFloor.FloorTopicInfo.Where(item => item.TopicType != Position.Top));
            UpdateProductModule(homeFloor);
            Context.Configuration.ValidateOnSaveEnabled = false;
            Context.SaveChanges();//保存更改
            Context.Configuration.ValidateOnSaveEnabled = true;
        }
Exemplo n.º 13
0
        void UpdateProductModule(HomeFloorInfo homeFloor)
        {
            //保存商品信息
            string[] tabNames = new string[] { "特价商品" };
            Context.FloorProductInfo.Remove(item => item.FloorId == homeFloor.Id);
            Context.FloorProductInfo.AddRange(homeFloor.FloorProductInfo);
            var oriHomeFloor = Context.HomeFloorInfo.FindById(homeFloor.Id);
            int i            = 0;

            //保存专题信息
            //context.FloorTopicInfo.Remove(item => item.FloorId == homeFloor.Id && item.TopicType == Position.MiddleOne);

            //var productTopics = homeFloor.FloorTopicInfo.Where(item => item.TopicType == Position.MiddleOne).ToArray();
            //foreach (var topic in productTopics)
            //{
            //    topic.TopicImage = TransferImage(topic.TopicImage, homeFloor.Id, Position.MiddleOne.ToString());
            //}
            //context.FloorTopicInfo.AddRange(productTopics);
        }
        public JsonResult SaveHomeFloorBasicInfo(long id, string name, string categoryIds)
        {
            string empty = string.Empty;
            bool   flag  = false;

            if (string.IsNullOrWhiteSpace(name))
            {
                empty = "楼层名称不能为空";
            }
            else if (name.Trim().Length <= 4)
            {
                name = name.Trim();
                try
                {
                    char[]             chrArray = new char[] { ',' };
                    IEnumerable <long> nums     =
                        from item in categoryIds.Split(chrArray)
                        where !string.IsNullOrWhiteSpace(item)
                        select long.Parse(item);

                    if (id <= 0)
                    {
                        HomeFloorInfo homeFloorInfo = ServiceHelper.Create <IFloorService>().AddHomeFloorBasicInfo(name, nums);
                        id = homeFloorInfo.Id;
                    }
                    else
                    {
                        ServiceHelper.Create <IFloorService>().UpdateFloorBasicInfo(id, name, nums);
                    }
                    flag = true;
                }
                catch (FormatException formatException)
                {
                    empty = "商品分类编号有误";
                }
            }
            else
            {
                empty = "楼层名称长度不能超过4个字";
            }
            return(Json(new { success = flag, msg = empty, id = id }));
        }
Exemplo n.º 15
0
 public void UpdateHomeFloorDetail(HomeFloorInfo homeFloor)
 {
     if (homeFloor.Id != 0)
     {
         HomeFloorInfo defaultTabName = context.HomeFloorInfo.FindById <HomeFloorInfo>(homeFloor.Id);
         defaultTabName.DefaultTabName = homeFloor.DefaultTabName;
         defaultTabName.FloorName      = homeFloor.FloorName;
         defaultTabName.SubName        = homeFloor.SubName;
     }
     else
     {
         long?nullable = new long?((long)0);
         nullable = new long?((
                                  from p in this.context.HomeFloorInfo
                                  select p.DisplaySequence).DefaultIfEmpty <long>().Max <long>());
         if (!nullable.HasValue)
         {
             nullable = new long?((long)0);
         }
         homeFloor.DisplaySequence = nullable.Value + (long)1;
         homeFloor.IsShow          = true;
         this.context.HomeFloorInfo.Add(homeFloor);
     }
     if (homeFloor.StyleLevel == 1)
     {
         UpdateProducts(homeFloor.Id, homeFloor.Himall_FloorTabls);
     }
     UpdateBrand(homeFloor.Id, homeFloor.FloorBrandInfo);
     UpdateTextLink(homeFloor.Id,
                    from item in homeFloor.FloorTopicInfo
                    where item.TopicType == Position.Top
                    select item);
     UpdataProductLink(homeFloor.Id,
                       from item in homeFloor.FloorTopicInfo
                       where item.TopicType != Position.Top
                       select item);
     context.Configuration.ValidateOnSaveEnabled = false;
     context.SaveChanges();
     context.Configuration.ValidateOnSaveEnabled = true;
 }
Exemplo n.º 16
0
 public void UpdateHomeFloorDetail(HomeFloorInfo homeFloor)
 {
     if (homeFloor.Id != 0)
     {
         HomeFloorInfo defaultTabName = context.HomeFloorInfo.FindById <HomeFloorInfo>(homeFloor.Id);
         defaultTabName.DefaultTabName = homeFloor.DefaultTabName;
         defaultTabName.FloorName      = homeFloor.FloorName;
         defaultTabName.SubName        = homeFloor.SubName;
     }
     else
     {
         long num = 0;
         num = (
             from p in context.HomeFloorInfo
             select p.DisplaySequence).Max <long>() + 1;
         homeFloor.DisplaySequence = num;
         homeFloor.IsShow          = true;
         context.HomeFloorInfo.Add(homeFloor);
     }
     if (homeFloor.StyleLevel == 1)
     {
         UpdateProducts(homeFloor.Id, homeFloor.ChemCloud_FloorTabls);
     }
     UpdateBrand(homeFloor.Id, homeFloor.FloorBrandInfo);
     UpdateTextLink(homeFloor.Id,
                    from item in homeFloor.FloorTopicInfo
                    where item.TopicType == Position.Top
                    select item);
     UpdataProductLink(homeFloor.Id,
                       from item in homeFloor.FloorTopicInfo
                       where item.TopicType != Position.Top
                       select item);
     context.Configuration.ValidateOnSaveEnabled = false;
     context.SaveChanges();
     context.Configuration.ValidateOnSaveEnabled = true;
 }
        public JsonResult SaveHomeFloorDetail(string floorDetail)
        {
            HomeFloorDetail homeFloorDetail = JsonConvert.DeserializeObject <HomeFloorDetail>(floorDetail);
            HomeFloorInfo   homeFloorInfo   = new HomeFloorInfo()
            {
                Id             = homeFloorDetail.Id,
                FloorName      = homeFloorDetail.Name,
                SubName        = homeFloorDetail.SubName,
                DefaultTabName = homeFloorDetail.DefaultTabName,
                StyleLevel     = homeFloorDetail.StyleLevel,
                FloorBrandInfo = (
                    from item in homeFloorDetail.Brands
                    select new FloorBrandInfo()
                {
                    BrandId = item.Id,
                    FloorId = homeFloorDetail.Id
                }).ToList(),
                FloorTopicInfo = (
                    from i in homeFloorDetail.TextLinks
                    select new FloorTopicInfo()
                {
                    FloorId = homeFloorDetail.Id,
                    TopicImage = "",
                    TopicName = i.Name,
                    Url = i.Url,
                    TopicType = Position.Top
                }).ToList()
            };
            HomeFloorInfo         list            = homeFloorInfo;
            List <FloorTopicInfo> floorTopicInfos = (
                from i in homeFloorDetail.ProductLinks
                select new FloorTopicInfo()
            {
                FloorId = homeFloorDetail.Id,
                TopicImage = (string.IsNullOrWhiteSpace(i.Name) ? "" : i.Name),
                TopicName = "",
                Url = i.Url,
                TopicType = (Position)((int)i.Id)
            }).ToList();

            foreach (FloorTopicInfo floorTopicInfo in floorTopicInfos)
            {
                list.FloorTopicInfo.Add(floorTopicInfo);
            }
            if (homeFloorDetail.Tabs != null)
            {
                list.Himall_FloorTabls = (
                    from item in homeFloorDetail.Tabs
                    select new FloorTablsInfo()
                {
                    Id = item.Id,
                    Name = item.Name,
                    FloorId = homeFloorDetail.Id,
                    Himall_FloorTablDetails = (
                        from d in item.Detail
                        select new FloorTablDetailsInfo()
                    {
                        Id = d.Id,
                        TabId = item.Id,
                        ProductId = d.ProductId
                    }).ToList()
                }).ToList();
            }
            ServiceHelper.Create <IFloorService>().UpdateHomeFloorDetail(list);
            return(Json(new { success = true }));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 楼层3
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult AddHomeFloorDetail3(long id = 0)
        {
            var homeFloorDetail = new HomeFloorDetail()
            {
                Id = 0
            };
            var homeFloor = _iFloorService.GetHomeFloor(id);

            if (homeFloor == null)
            {
                homeFloor = new HomeFloorInfo();
                var ProductLinks = new List <HomeFloorDetail.TextLink>();
                for (int i = 0; i < 1; i++)
                {
                    ProductLinks.Add(new HomeFloorDetail.TextLink
                    {
                        Id   = i,
                        Name = "",
                        Url  = ""
                    });
                }
                homeFloorDetail.ProductLinks = ProductLinks;
                homeFloorDetail.StyleLevel   = 2;
            }
            else
            {
                homeFloorDetail.Id             = homeFloor.Id;
                homeFloorDetail.DefaultTabName = homeFloor.DefaultTabName;

                //图片
                homeFloorDetail.ProductLinks = homeFloor.FloorTopicInfo
                                               .Where(item => item.TopicType != Position.Top)
                                               .Select(item => new HomeFloorDetail.TextLink()
                {
                    Id   = (long)item.TopicType,
                    Name = item.Url,
                    Url  = item.TopicImage,
                }).OrderBy(i => i.Id);


                //商品
                homeFloorDetail.ProductModules = homeFloor.FloorProductInfo
                                                 .Where(item => item.FloorId == homeFloor.Id).OrderBy(p => p.Id)
                                                 .Select(item => new HomeFloorDetail.ProductModule()
                {
                    Id          = item.Id,
                    price       = item.ProductInfo.MinSalePrice,
                    ProductId   = item.ProductId,
                    productImg  = HimallIO.GetProductSizeImage(item.ProductInfo.ImagePath, 1, (int)ImageSize.Size_50),
                    productName = item.ProductInfo.ProductName,
                    Tab         = item.Tab
                });
            }

            if (homeFloorDetail.Tabs == null)
            {
                homeFloorDetail.Tabs = new List <HomeFloorDetail.Tab>();
            }
            ViewBag.FloorName = homeFloor == null ? "" : homeFloor.FloorName;
            ViewBag.SubName   = homeFloor == null ? "" : homeFloor.SubName;
            return(View(homeFloorDetail));
        }
Exemplo n.º 19
0
 private void UpdateProductModule(HomeFloorInfo homeFloor)
 {
 }
        public ActionResult AddHomeFloorDetail2(long id = 0L)
        {
            string          str;
            string          str1;
            HomeFloorDetail homeFloorDetail = new HomeFloorDetail()
            {
                Id = 0
            };
            HomeFloorInfo homeFloor = ServiceHelper.Create <IFloorService>().GetHomeFloor(id);

            if (homeFloor != null)
            {
                homeFloorDetail.Id             = homeFloor.Id;
                homeFloorDetail.DefaultTabName = homeFloor.DefaultTabName;
                homeFloorDetail.TextLinks      =
                    from item in homeFloor.FloorTopicInfo
                    where item.TopicType == Position.Top
                    select new HomeFloorDetail.TextLink()
                {
                    Id   = item.Id,
                    Name = item.TopicName,
                    Url  = item.Url
                };
                homeFloorDetail.ProductLinks =
                    from item in homeFloor.FloorTopicInfo
                    where item.TopicType != Position.Top
                    select new HomeFloorDetail.TextLink()
                {
                    Id   = (long)item.TopicType,
                    Name = item.Url,
                    Url  = item.TopicImage
                } into i
                orderby i.Id
                select i;
                homeFloorDetail.Tabs =
                    from item in homeFloor.Himall_FloorTabls
                    where item.FloorId == homeFloor.Id
                    select item into p
                    orderby p.Id
                    select p into item
                    select new HomeFloorDetail.Tab()
                {
                    Id     = item.Id,
                    Detail =
                        from detail in item.Himall_FloorTablDetails
                        where detail.TabId == item.Id
                        select detail into p
                        select new HomeFloorDetail.ProductDetail()
                    {
                        Id        = p.Id,
                        ProductId = p.ProductId
                    },
                    Name  = item.Name,
                    Count = (
                        from detail in item.Himall_FloorTablDetails
                        where detail.TabId == item.Id
                        select detail).Count(),
                    Ids = ArrayToString((
                                            from detail in item.Himall_FloorTablDetails
                                            where detail.TabId == item.Id
                                            select detail into p
                                            select p.ProductId).ToArray())
                };
            }
            else
            {
                homeFloor = new HomeFloorInfo();
                List <HomeFloorDetail.TextLink> textLinks = new List <HomeFloorDetail.TextLink>();
                for (int num = 0; num < 12; num++)
                {
                    HomeFloorDetail.TextLink textLink = new HomeFloorDetail.TextLink()
                    {
                        Id   = num,
                        Name = "",
                        Url  = ""
                    };
                    textLinks.Add(textLink);
                }
                homeFloorDetail.ProductLinks = textLinks;
                homeFloorDetail.StyleLevel   = 1;
            }
            if (homeFloorDetail.Tabs == null)
            {
                homeFloorDetail.Tabs = new List <HomeFloorDetail.Tab>();
            }
            dynamic viewBag = base.ViewBag;

            str = (homeFloor == null ? "" : homeFloor.FloorName);
            viewBag.FloorName = str;
            dynamic obj = base.ViewBag;

            str1        = (homeFloor == null ? "" : homeFloor.SubName);
            obj.SubName = str1;
            return(View(homeFloorDetail));
        }
Exemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult AddHomeFloorDetail9(long id = 0)
        {
            var homeFloorDetail = new HomeFloorDetail()
            {
                Id = 0
            };
            var homeFloor = _iFloorService.GetHomeFloor(id);

            if (homeFloor == null)
            {
                homeFloor = new HomeFloorInfo();
                var ProductLinks = new List <HomeFloorDetail.TextLink>();
                for (int i = 0; i < 13; i++)
                {
                    ProductLinks.Add(new HomeFloorDetail.TextLink
                    {
                        Id   = i,
                        Name = "",
                        Url  = ""
                    });
                }
                homeFloorDetail.ProductLinks = ProductLinks;
                homeFloorDetail.StyleLevel   = 1;
            }
            else
            {
                homeFloorDetail.Id             = homeFloor.Id;
                homeFloorDetail.DefaultTabName = homeFloor.DefaultTabName;

                homeFloorDetail.ProductLinks = homeFloor.FloorTopicInfo
                                               .Where(item => item.TopicType != Position.Top)
                                               .Select(item => new HomeFloorDetail.TextLink()
                {
                    Id   = (long)item.TopicType,
                    Name = item.Url,
                    Url  = item.TopicImage,
                }).OrderBy(i => i.Id);

                //填充文字链接
                homeFloorDetail.TextLinks = homeFloor.FloorTopicInfo.Where(item => item.TopicType == Position.Top).Select(item => new HomeFloorDetail.TextLink()
                {
                    Id   = item.Id,
                    Name = item.TopicName,
                    Url  = item.Url
                });
                homeFloorDetail.Tabs = homeFloor.Himall_FloorTabls
                                       .Where(item => item.FloorId == homeFloor.Id).OrderBy(p => p.Id)
                                       .Select(item => new HomeFloorDetail.Tab()
                {
                    Id     = item.Id,
                    Detail = item.Himall_FloorTablDetails.Where(detail => detail.TabId == item.Id)
                             .Select(p => new HomeFloorDetail.ProductDetail()
                    {
                        Id        = p.Id,
                        ProductId = p.ProductId
                    }),
                    Name  = item.Name,
                    Count = item.Himall_FloorTablDetails.Where(detail => detail.TabId == item.Id).Count(),
                    Ids   = ArrayToString(item.Himall_FloorTablDetails.Where(detail => detail.TabId == item.Id).Select(p => p.ProductId).ToArray())
                });
            }

            if (homeFloorDetail.Tabs == null)
            {
                homeFloorDetail.Tabs = new List <HomeFloorDetail.Tab>();
            }
            ViewBag.FloorName = homeFloor == null ? "" : homeFloor.FloorName;
            ViewBag.SubName   = homeFloor == null ? "" : homeFloor.SubName;
            return(View(homeFloorDetail));
        }