public RedirectToRouteResult Delete(SkillProfile skillProfile, string skillPath)
 {
     UserSkill skillToDelete = skillProfile.Find(s => s.GetSkillPath(skillProfile).Equals(skillPath));
     UserSkill parentSkill = skillProfile.Find(s => s.Id.Equals(skillToDelete.ParentId));
     skillProfile.Remove(skillToDelete);
     return RedirectToAction("Index", "SkillProfile", new { skillPath = parentSkill.GetSkillPath(skillProfile)});
 }
        public RedirectToRouteResult MoveWhenVerbEqualsPost(SkillProfile skillProfile, MoveUserSkillViewModel moveSkillViewModel)
        {
            UserSkill skillToMove = skillProfile.GetUserSkill(moveSkillViewModel.FromPath);
            UserSkill parentSkill = skillProfile.GetUserSkill(moveSkillViewModel.ToPath);
            skillToMove.ParentId = parentSkill.Id;
            _skillProfileRepository.Save(skillProfile);

            return RedirectToAction("Index", "SkillProfile", new { skillPath = moveSkillViewModel.ToPath });
        }
 public void Save(SkillProfile skillProfile)
 {
     using (Stream stream = File.Open(FileName, FileMode.Create))
     {
         XmlSerializer xs = new XmlSerializer(typeof(SkillProfile));
         xs.Serialize(stream, skillProfile);
         stream.Flush();
         stream.Close();
     }
 }
        public RedirectToRouteResult Move(SkillProfile skillProfile)
        {
            foreach (var childGuid in _moveSkillViewModel.SelectedItems) {
                foreach (var parentGuid in _moveSkillViewModel.TargetItems) {
                    skillProfile.FirstOrDefault(s => s.Id.Equals(childGuid)).ParentId = parentGuid;
                }
            }

            _skillProfileRepository.Save(skillProfile);
            return RedirectToAction("Index", "SkillProfile");
        }
        public RedirectToRouteResult Copy(SkillProfile skillProfile, MoveUserSkillViewModel moveSkillViewModel)
        {
            UserSkill skillToCopy = skillProfile.GetUserSkill(moveSkillViewModel.FromPath);
            UserSkill parentSkill = skillProfile.GetUserSkill(moveSkillViewModel.ToPath);
            UserSkill copy = skillToCopy.Clone();
            copy.ParentId = parentSkill.Id;
            copy.Children.Clear();
            skillProfile.Add(copy);
            _skillProfileRepository.Save(skillProfile);

            return RedirectToAction("Index", "SkillProfile", new { skillPath = moveSkillViewModel.ToPath });
        }
        public ActionResult DoAction(SkillProfile skillProfile, string selectedAction, Guid[] selectedItems, string rootId)
        {
            switch (selectedAction.ToUpper()) {

                case "MOVE":
                    #region Get List of skills to display from the root

                    UserSkill rootSkillToDisplay = null;

                    Guid displayRootId;
                    if (!string.IsNullOrEmpty(rootId) && Guid.TryParse(rootId, out displayRootId)) {
                        rootSkillToDisplay = skillProfile.FirstOrDefault(s => s.Id == displayRootId);
                        rootSkillToDisplay.Children.AddRange(skillProfile.FindAll(s => s.ParentId == displayRootId));
                    }
                    else {
                        rootSkillToDisplay = new UserSkill();
                        var childSkills = skillProfile.FindAll(s => s.ParentId == null || s.ParentId == Guid.Empty);
                        rootSkillToDisplay.Children.AddRange(childSkills);
                    }

                    #endregion
                    #region Construct ViewModel with list of skills to display and selected skills to move

                    _moveSkillViewModel = new MoveSkillViewModel {Root = rootSkillToDisplay, SelectedItems = selectedItems};

                    #endregion
                    return RedirectToAction("Move");
                case "DELETE":

                    // return delete view to confirm deletion

                    //foreach (Guid guid in selectedItems)
                    //{
                    //    skillProfile.RemoveAll(s => s.Id.Equals(guid));
                    //}

                    break;
            }

            return View("YourProfile", new SkillProfileViewModelBase { SkillProfile = skillProfile });
        }
        public void Should_Return_Skill_For_Path()
        {
            //Arrange
            Guid g1 = Guid.NewGuid();
            Guid g2 = Guid.NewGuid();
            Guid g3 = Guid.NewGuid();
            Guid g4 = Guid.NewGuid();
            SkillProfile skillProfile = new SkillProfile();
            skillProfile.Add(new UserSkill { Id = g1, SkillName = g1.ToString()} );
            skillProfile.Add(new UserSkill { Id = g2, ParentId  = g1, SkillName = g2.ToString()} );
            skillProfile.Add(new UserSkill { Id = g3, ParentId  = g2, SkillName = g3.ToString()} );
            skillProfile.Add(new UserSkill { Id = g4, ParentId  = g3, SkillName = g4.ToString()} );

            UserSkill s4 = skillProfile.FirstOrDefault(s => s.SkillName.Equals(g4.ToString()));
            string s4Path = s4.GetSkillPath(skillProfile);

            //Act
            UserSkill userSkillFound = skillProfile.GetUserSkill(s4Path);

            //Assert
            Assert.AreSame(s4, userSkillFound);
        }
 public ViewResult Move(SkillProfile skillProfile, string skillPath)
 {
     return View("SelectUserSkill", new MoveUserSkillViewModel { SkillProfile = skillProfile, SkillPath = skillPath});
 }
 public UserSkillViewModelItem(UserSkill userSkill, SkillProfile skillProfile)
 {
     UserSkill = userSkill;
     SkillProfile = skillProfile;
 }
Beispiel #10
0
 public SkillControlEntry(Mobile from, SkillProfile stone)
     : base(5101, 1)
 {
     m_From    = from;
     m_profile = stone;
 }
 public ViewResult Detail(SkillProfile skillProfile, Guid userSkillId)
 {
     var userSkill = skillProfile.GetChildren(skillProfile.FirstOrDefault(s=>s.Id.Equals(userSkillId)));
     return View(new UserSkillDetailViewModel { UserSkill = userSkill });
 }