/// <summary>
 /// 保存详细内容
 /// </summary>
 private void SetContent()
 {
     //内容
     foreach (OptionsModel option in optionsList)
     {
         ProjectContentModel projectContent = new ProjectContentModel();
         projectContent.ProId    = project.Pkid;
         projectContent.OptionId = option.Pkid;
         projectContent.Content  = Request.Form["content" + option.Pkid.ToString()];
         bll_projectContent.Update(projectContent);
     }
 }
        public ActionResult ProjectDetail(int?id)
        {
            ProjectModel model;
            var          facilities = _service.GetAllFacilities();

            if (!Equals(id, null))
            {
                var project        = _service.GetProjectById(id.Value);
                var projectContent = project.project_content.Select(p => new ProjectContentModel()
                {
                    Id          = p.project_content_id,
                    Name        = p.name,
                    Description = p.description
                }).ToList();

                var projectOverview = new List <ProjectOverviewModel>();
                if (project.project_overview.Count > 0)
                {
                    var overviewContent = project.project_overview.Where(p => p.language == 0).Select(p => new ProjectOverviewContentModel()
                    {
                        Id      = p.project_overview_id,
                        Content = p.content
                    }).ToList();
                    projectOverview.Add(new ProjectOverviewModel()
                    {
                        ContentList = overviewContent
                    });
                    overviewContent = project.project_overview.Where(p => p.language == 1).Select(p => new ProjectOverviewContentModel()
                    {
                        Id      = p.project_overview_id,
                        Content = p.content
                    }).ToList();
                    projectOverview.Add(new ProjectOverviewModel()
                    {
                        ContentList = overviewContent
                    });
                    overviewContent = project.project_overview.Where(p => p.language == 2).Select(p => new ProjectOverviewContentModel()
                    {
                        Id      = p.project_overview_id,
                        Content = p.content
                    }).ToList();
                    projectOverview.Add(new ProjectOverviewModel()
                    {
                        ContentList = overviewContent
                    });
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        var contentList = new List <ProjectOverviewContentModel>();
                        for (int j = 0; j < 9; j++)
                        {
                            var c = new ProjectOverviewContentModel()
                            {
                                Id = 0, Language = i
                            };
                            contentList.Add(c);
                        }
                        var content = new ProjectOverviewModel()
                        {
                            ContentList = contentList
                        };
                        projectOverview.Add(content);
                    }
                }

                var facilityList = new List <FacilityModel>();
                foreach (var item in facilities)
                {
                    var flag = false;
                    foreach (var fac in project.project_facility)
                    {
                        if (item.facility_id == fac.facility_id)
                        {
                            flag = true;
                            break;
                        }
                    }
                    var check = new FacilityModel()
                    {
                        Id       = item.facility_id,
                        Content  = _service.ConvertFacilityContentToModel(item.facility_content.FirstOrDefault(p => p.language == 0)),
                        Selected = flag
                    };
                    facilityList.Add(check);
                }

                //var facilityList = project.project_facility.Select(p => new FacilityModel()
                //{
                //    Id = p.facility_id,
                //    Content = _service.ConvertFacilityContentToModel(p.facility.facility_content.FirstOrDefault(q => q.language == 0))
                //}).ToList();
                model = new ProjectModel()
                {
                    Id           = project.project_id,
                    Img          = project.img,
                    Type         = project.type,
                    Slide1       = project.slide_1,
                    Slide2       = project.slide_2,
                    Slide3       = project.slide_3,
                    ContentList  = projectContent,
                    OverviewList = projectOverview,
                    FacilityList = facilityList,
                    Logo         = project.logo,
                    Address      = project.address,
                    Latitude     = project.latitude,
                    Longitude    = project.longitude
                };
            }
            else
            {
                var projectContent = new List <ProjectContentModel>();
                for (int i = 0; i < 3; i++)
                {
                    var content = new ProjectContentModel()
                    {
                        Id       = 0,
                        Language = i
                    };
                    projectContent.Add(content);
                }

                var projectOverview = new List <ProjectOverviewModel>();
                for (int i = 0; i < 3; i++)
                {
                    var contentList = new List <ProjectOverviewContentModel>();
                    for (int j = 0; j < 9; j++)
                    {
                        var c = new ProjectOverviewContentModel()
                        {
                            Id = 0, Language = i
                        };
                        contentList.Add(c);
                    }
                    var content = new ProjectOverviewModel()
                    {
                        ContentList = contentList
                    };
                    projectOverview.Add(content);
                }
                model = new ProjectModel()
                {
                    Id           = 0,
                    ContentList  = projectContent,
                    OverviewList = projectOverview,
                    Type         = 0,
                    FacilityList = facilities.Select(p => new FacilityModel()
                    {
                        Id       = p.facility_id,
                        Content  = _service.ConvertFacilityContentToModel(p.facility_content.FirstOrDefault(q => q.language == 0)),
                        Selected = false
                    }).ToList()
                };
            }

            return(View(model));
        }