コード例 #1
0
ファイル: PicturesViewModel.cs プロジェクト: bahilo/Portfolio
 public PicturesViewModel()
 {
     ProjectDetail = new ProjectDetailsViewModel();
     Education = new EducationViewModel();
     Experience = new ExperiencesViewModel();
     Skill = new SkillsViewModel();/**/
 }
コード例 #2
0
 // GET: Experiences/Create
 public ActionResult Create()
 {
     var experience = new ExperiencesViewModel();
     experience.Skills = db.Skills.ToList();
     return View(experience);
 }
コード例 #3
0
        private void addOrUpdateSkillWithObjects(ExperiencesViewModel experience, IEnumerable<string> listSkillOfExperiencesId, IEnumerable<string> isSkillSelected)
        {
            // Project Skills handling
            List<int> listAddedSkillsId = new List<int>();
            if (isSkillSelected != null)
            {
                int id;
                SkillsViewModel newSkill;
                for (int i = 0; i < isSkillSelected.Count(); i++)
                {
                    string isSelected = isSkillSelected.ElementAt(i).Split('-').ToList()[0];
                    string isSelectedId = isSkillSelected.ElementAt(i).Split('-').ToList()[1];
                    id = Int32.Parse(isSelectedId);
                    newSkill = db.Skills.Where(y => y.ID == id).Include("CategoryViewModel").Include("LevelsViewModel").Include(x => x.Projects).Include(x => x.Projects.Select(s => s.ProjectDetail)).Include(x => x.Experiences).DefaultIfEmpty().Single();
                    //var projectWithDetail = db.Projects.Where(p => p.Skills.Where(y => y.ID == newSkill.ID).Join(p.ProjectDetail)).Include(z=>z.);
                    
                    if (isSelected == "true")
                    {
                        experience.Skills.Add(newSkill);
                        listAddedSkillsId.Add(id);
                    }
                }
            }

            // removing uncheck Projects skills
            if (listSkillOfExperiencesId != null)
            {
                foreach (var skillIdString in listSkillOfExperiencesId)
                {
                    var skillId = Int32.Parse(skillIdString);
                    if ((listAddedSkillsId != null && !listAddedSkillsId.Contains(skillId)) || listAddedSkillsId == null)
                    {
                        var skillToRemove = db.Skills.Where(x => x.ID == skillId).Include("CategoryViewModel").Include("LevelsViewModel").First();
                        experience.Skills.Remove(skillToRemove);
                    }
                }
            }

        }