Пример #1
0
        public ActionResult GetLayoutDetails(int layoutId)
        {
            Layout layout = db.Layout.Find(layoutId);
            List <LayoutDecorate>       decorateData       = new List <LayoutDecorate>();
            List <LayoutSpotYuanZhuang> spotYuanZhuangData = new List <LayoutSpotYuanZhuang>();
            List <LayoutSpotShiGong>    spotShiGongData    = new List <LayoutSpotShiGong>();
            LayoutDetails layoutData = new LayoutDetails();

            layoutData.LayoutId            = layout.Id;
            layoutData.LayoutName          = layout.LayoutName;
            layoutData.LayoutPic           = ConfigurationManager.AppSettings["ResourceUrl"] + layout.LayoutPic;
            layoutData.LayoutAdvantages    = layout.Advantage;
            layoutData.LayoutDisadvantages = layout.Disadvantage;

            List <Decorate>    decorateList   = db.Decorate.Where(item => item.LayoutId == layout.Id).ToList();
            List <SpotPics>    spotPicsList   = db.SpotPics.Where(item => item.LayoutId == layout.Id).ToList();
            SpotYuanZhuangData yuanZhuangData = new SpotYuanZhuangData();
            SpotShiGongData    shiGongData    = new SpotShiGongData();

            foreach (Decorate decorate in decorateList)
            {
                LayoutDecorate decoratedata = new LayoutDecorate();
                decoratedata.DecorateId    = decorate.Id;
                decoratedata.DecorateIndex = ConfigurationManager.AppSettings["ResourceUrl"] + decorate.DecorateIndex;
                decoratedata.Is360         = (decorate.Decorate360 == null) ? 0 : 1;
                decorateData.Add(decoratedata);
            }
            foreach (SpotPics spotPic in spotPicsList.Where(item => item.Category == 1))
            {
                LayoutSpotYuanZhuang yuanzhuangdata = new LayoutSpotYuanZhuang();
                yuanzhuangdata.SpotId    = spotPic.Id;
                yuanzhuangdata.SpotIndex = ConfigurationManager.AppSettings["ResourceUrl"] + spotPic.SpotIndex;
                //yuanzhuangdata.SpotPics = spotPic.SpotDetails;
                spotYuanZhuangData.Add(yuanzhuangdata);
            }
            foreach (SpotPics spotPic in spotPicsList.Where(item => item.Category == 2))
            {
                LayoutSpotShiGong shigongdata = new LayoutSpotShiGong();
                shigongdata.SpotId    = spotPic.Id;
                shigongdata.SpotIndex = ConfigurationManager.AppSettings["ResourceUrl"] + spotPic.SpotIndex;
                //shigongdata.SpotPics = spotPic.SpotDetails;
                spotShiGongData.Add(shigongdata);
            }
            layoutData.Decotate           = decorateData;
            layoutData.SpotYuanZhuangData = spotYuanZhuangData;
            layoutData.SpotShiGongData    = spotShiGongData;
            return(Json(new { data = layoutData }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult GetBuildingData(int id)
        {
            Building     building   = db.Building.Find(id);
            string       buildingId = id.ToString();
            UpdateRecord record     = db.UpdateRecord.Where(item => item.BuildingId == buildingId).FirstOrDefault();

            if (record == null)
            {
                record            = new UpdateRecord();
                record.BuildingId = buildingId;
                record.UpdateTime = DateTime.Now;
                db.UpdateRecord.Add(record);
                db.SaveChanges();
            }
            BuildingData buildingData = new BuildingData();

            buildingData.BuildingId    = id;
            buildingData.BuildingName  = building.BuildingName;
            buildingData.BuildingIndex = ConfigurationManager.AppSettings["ResourceUrl"] + building.BuildingIndex;
            buildingData.BuildingPics  = building.BuildingPics.Substring(0, building.BuildingPics.Length - 1).Split(' ');
            for (int i = 0; i < buildingData.BuildingPics.Length; i++)
            {
                buildingData.BuildingPics[i] = ConfigurationManager.AppSettings["ResourceUrl"] + buildingData.BuildingPics[i];
            }
            buildingData.BuildingIntro     = building.BuildingIntro;
            buildingData.BuildingAD        = building.BuildingAD;
            buildingData.BuildingAroundPic = ConfigurationManager.AppSettings["ResourceUrl"] + building.BuildingCate;
            buildingData.BuildingDeco      = building.BuildingDecorate;
            buildingData.BuildingUpdate    = record.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
            List <LayoutData> layoutDataList = new List <LayoutData>();

            List <Layout> layoutList = db.Layout.Where(item => item.BuildingId == id).ToList();

            foreach (Layout layout in layoutList)
            {
                List <DecorateData>       decorateData       = new List <DecorateData>();
                List <SpotYuanZhuangData> spotYuanZhuangData = new List <SpotYuanZhuangData>();
                List <SpotShiGongData>    spotShiGongData    = new List <SpotShiGongData>();
                LayoutData layoutData = new LayoutData();
                layoutData.LayoutId            = layout.Id;
                layoutData.LayoutName          = layout.LayoutName;
                layoutData.LayoutPic           = ConfigurationManager.AppSettings["ResourceUrl"] + layout.LayoutPic;
                layoutData.LayoutAdvantages    = layout.Advantage;
                layoutData.LayoutDisadvantages = layout.Disadvantage;

                List <Decorate>    decorateList   = db.Decorate.Where(item => item.LayoutId == layout.Id).ToList();
                List <SpotPics>    spotPicsList   = db.SpotPics.Where(item => item.LayoutId == layout.Id).ToList();
                SpotYuanZhuangData yuanZhuangData = new SpotYuanZhuangData();
                SpotShiGongData    shiGongData    = new SpotShiGongData();
                foreach (Decorate decorate in decorateList)
                {
                    DecorateData decoratedata = new DecorateData();
                    decoratedata.DecorateId    = decorate.Id;
                    decoratedata.DecorateIndex = ConfigurationManager.AppSettings["ResourceUrl"] + decorate.DecorateIndex;
                    if (decorate.DecoratePics != null)
                    {
                        decoratedata.DecoratePics = decorate.DecoratePics.Substring(0, decorate.DecoratePics.Length - 1).Split(' ');
                        for (int i = 0; i < decoratedata.DecoratePics.Length; i++)
                        {
                            decoratedata.DecoratePics[i] = ConfigurationManager.AppSettings["ResourceUrl"] + decoratedata.DecoratePics[i];
                        }
                    }
                    else
                    {
                        decoratedata.DecoratePics = new string[] { "" };
                    }

                    decoratedata.Decorate360 = decorate.Decorate360;
                    decorateData.Add(decoratedata);
                }
                foreach (SpotPics spotPic in spotPicsList.Where(item => item.Category == 1))
                {
                    SpotYuanZhuangData yuanzhuangdata = new SpotYuanZhuangData();
                    yuanzhuangdata.SpotId    = spotPic.Id;
                    yuanzhuangdata.SpotIndex = ConfigurationManager.AppSettings["ResourceUrl"] + spotPic.SpotIndex;
                    yuanzhuangdata.SpotPics  = spotPic.SpotDetails.Substring(0, spotPic.SpotDetails.Length - 1).Split(' ');
                    for (int i = 0; i < yuanzhuangdata.SpotPics.Length; i++)
                    {
                        yuanzhuangdata.SpotPics[i] = ConfigurationManager.AppSettings["ResourceUrl"] + yuanzhuangdata.SpotPics[i];
                    }
                    spotYuanZhuangData.Add(yuanzhuangdata);
                }
                foreach (SpotPics spotPic in spotPicsList.Where(item => item.Category == 2))
                {
                    SpotShiGongData shigongdata = new SpotShiGongData();
                    shigongdata.SpotId    = spotPic.Id;
                    shigongdata.SpotIndex = ConfigurationManager.AppSettings["ResourceUrl"] + spotPic.SpotIndex;
                    shigongdata.SpotPics  = spotPic.SpotDetails.Substring(0, spotPic.SpotDetails.Length - 1).Split(' ');
                    for (int i = 0; i < shigongdata.SpotPics.Length; i++)
                    {
                        shigongdata.SpotPics[i] = ConfigurationManager.AppSettings["ResourceUrl"] + shigongdata.SpotPics[i];
                    }
                    spotShiGongData.Add(shigongdata);
                }
                layoutData.Decotate           = decorateData;
                layoutData.SpotYuanZhuangData = spotYuanZhuangData;
                layoutData.SpotShiGongData    = spotShiGongData;

                layoutDataList.Add(layoutData);
            }
            buildingData.LayoutData = layoutDataList;
            return(Json(new { data = buildingData }, JsonRequestBehavior.AllowGet));
        }