public ActionResult SkillsAndCv(SkillSelection Skills)
        {
            using (var db = new ApplicationDbContext())
            {
                var userId = User.Identity.GetUserId();

                var user = db.Users.SingleOrDefault(x => x.Id == userId);
                var data = Request.Form["Skills"].Split(',');
                if (user.InterestedSkills == null)
                {
                    user.InterestedSkills = new List <Skill>();
                }


                foreach (var skill in data)
                {
                    var id      = int.Parse(skill);
                    var dbSkill = db.skills.SingleOrDefault(x => x.Id == id);

                    user.InterestedSkills.Add(dbSkill);

                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 2
0
        public void IfRandomFociQuantityIsPositive_ThrowExceptionWhenTestingEqualToSkillSelection(int selectionQuantity, int otherSelectionQuantity)
        {
            selection.SkillName          = "skill";
            selection.RandomFociQuantity = selectionQuantity;

            var otherSelection = new SkillSelection();

            otherSelection.SkillName          = "skill";
            otherSelection.RandomFociQuantity = otherSelectionQuantity;

            Assert.That(() => selection.IsEqualTo(otherSelection), Throws.InvalidOperationException.With.Message.EqualTo("Cannot test equality of a skill selection while random foci quantity is positive"));
        }
Exemplo n.º 3
0
        public SkillSelection SelectFor(string skill)
        {
            var data = collectionSelector.SelectFrom(TableNameConstants.Collection.SkillData, skill).ToArray();

            var selection = new SkillSelection();

            selection.BaseAbilityName    = data[DataIndexConstants.SkillSelectionData.BaseAbilityNameIndex];
            selection.SkillName          = data[DataIndexConstants.SkillSelectionData.SkillNameIndex];
            selection.RandomFociQuantity = Convert.ToInt32(data[DataIndexConstants.SkillSelectionData.RandomFociQuantityIndex]);
            selection.Focus = data[DataIndexConstants.SkillSelectionData.FocusIndex];

            return(selection);
        }
Exemplo n.º 4
0
        public void SkillSelectionEqualsSkillSelection(string selectionName, string selectionFocus, string skillName, string skillFocus, bool shouldEqual)
        {
            selection.Focus     = selectionFocus;
            selection.SkillName = selectionName;

            var otherSelection = new SkillSelection();

            otherSelection.SkillName = skillName;
            otherSelection.Focus     = skillFocus;

            var isEqual = selection.IsEqualTo(otherSelection);

            Assert.That(isEqual, Is.EqualTo(shouldEqual));
        }
Exemplo n.º 5
0
        private IEnumerable <SkillSelection> ExplodeSelectedSkill(SkillSelection skillSelection)
        {
            if (skillSelection.RandomFociQuantity == 0)
            {
                return new[] { skillSelection }
            }
            ;

            var skillFoci = collectionsSelector.SelectFrom(TableNameConstants.Collection.SkillGroups, skillSelection.SkillName).ToList();

            if (skillSelection.RandomFociQuantity >= skillFoci.Count)
            {
                return(skillFoci.Select(f => new SkillSelection
                {
                    BaseAbilityName = skillSelection.BaseAbilityName,
                    SkillName = skillSelection.SkillName,
                    Focus = f,
                    ClassSkill = skillSelection.ClassSkill
                }));
            }

            var selections = new List <SkillSelection>();

            while (skillSelection.RandomFociQuantity > selections.Count)
            {
                var focus     = collectionsSelector.SelectRandomFrom(skillFoci);
                var selection = new SkillSelection();

                selection.BaseAbilityName = skillSelection.BaseAbilityName;
                selection.SkillName       = skillSelection.SkillName;
                selection.Focus           = focus;
                selection.ClassSkill      = skillSelection.ClassSkill;

                selections.Add(selection);
                skillFoci.Remove(focus);
            }

            return(selections);
        }
Exemplo n.º 6
0
 public void Setup()
 {
     selection = new SkillSelection();
 }