예제 #1
0
        public JsonResult SaveHomeFloorDetail(string floorDetail)
        {
            var floorDetailObj = Newtonsoft.Json.JsonConvert.DeserializeObject <HomeFloorDetail>(floorDetail);

            var homeFloor = new Model.HomeFloorInfo()
            {
                Id             = floorDetailObj.Id,
                FloorName      = floorDetailObj.Name,
                SubName        = floorDetailObj.SubName,
                DefaultTabName = floorDetailObj.DefaultTabName,
                StyleLevel     = floorDetailObj.StyleLevel,
                FloorBrandInfo = floorDetailObj.Brands.Select(item => new FloorBrandInfo()
                {
                    BrandId = item.Id,
                    FloorId = floorDetailObj.Id,
                }).ToList(),
                FloorTopicInfo = floorDetailObj.TextLinks.Select(i => new FloorTopicInfo
                {
                    FloorId    = floorDetailObj.Id,
                    TopicImage = "",
                    TopicName  = i.Name,
                    Url        = i.Url,
                    TopicType  = Position.Top
                }).ToList(),
            };
            var productLink = floorDetailObj.ProductLinks.Select(i => new FloorTopicInfo
            {
                FloorId    = floorDetailObj.Id,
                TopicImage = String.IsNullOrWhiteSpace(i.Name) ? "" : i.Name,
                TopicName  = "",
                Url        = i.Url,
                TopicType  = (Position)i.Id
            }).ToList();

            foreach (var item in productLink)
            {
                homeFloor.FloorTopicInfo.Add(item);
            }

            if (floorDetailObj.Tabs != null)
            {
                homeFloor.Himall_FloorTabls = floorDetailObj.Tabs.Select(item => new FloorTablsInfo()
                {
                    Id      = item.Id,
                    Name    = item.Name,
                    FloorId = floorDetailObj.Id,
                    Himall_FloorTablDetails = item.Detail.Select(d => new FloorTablDetailsInfo()
                    {
                        Id        = d.Id,
                        TabId     = item.Id,
                        ProductId = d.ProductId
                    }).ToList()
                }).ToList();
            }

            if (floorDetailObj.ProductModules != null)
            {
                homeFloor.FloorProductInfo = floorDetailObj.ProductModules.Select(item => new FloorProductInfo()
                {
                    Id        = item.Id,
                    FloorId   = floorDetailObj.Id,
                    ProductId = item.ProductId,
                    Tab       = item.Tab
                }).ToList();
            }

            _iFloorService.UpdateHomeFloorDetail(homeFloor);

            return(Json(new
            {
                success = true
            }));
        }