public async Task <IActionResult> PutProfileQuestion([FromRoute] int id, [FromBody] ProfileQuestion profileQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != profileQuestion.Id)
            {
                return(BadRequest());
            }

            _context.Entry(profileQuestion).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProfileQuestionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PostProfileQuestion([FromBody] ProfileQuestion profileQuestion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ProfileQuestion.Add(profileQuestion);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProfileQuestion", new { id = profileQuestion.Id }, profileQuestion));
        }
Exemplo n.º 3
0
 public QuestionPoco(ANSWER answer, SETS set, ProfileQuestion profileQuestion)
     : this(answer)
 {
     this.ProfileQuestionData = profileQuestion;
     this.DictionaryStandards[set.Set_Name] = set;
 }
Exemplo n.º 4
0
 /// <summary>
 ///      Initializes a new instance of the ProfileItem using the specified ProfileQuestion and the answer.
 /// </summary>
 /// <param name="question">the specified ProfileQuestion.</param>
 /// <param name="answer">the answer</param>
 public ProfileItem(ProfileQuestion question, string answer) : this( question)
 {
     Answer = answer ?? throw new ArgumentNullException(nameof(answer));
 }
Exemplo n.º 5
0
 /// <summary>
 ///      Initializes a new instance of the ProfileItem using the specified ProfileQuestion.
 /// </summary>
 /// <param name="question">the specified ProfileQuestion.</param>
 public ProfileItem(ProfileQuestion question)
 {
     Question = question ?? throw new ArgumentNullException(nameof(question));
 }
Exemplo n.º 6
0
        private static int CalculateMatchPercentage(ProfileQuestion[] profileQuestions, List<ProfileAnswer> profileAnswers1,
            List<ProfileAnswer> profileAnswers2)
        {
            decimal points = 0;
            int count = 0;

            foreach (ProfileQuestion profileQuestion in profileQuestions)
            {
                if (profileQuestion.MatchField == null
                    || profileQuestion.EditStyle == ProfileQuestion.eEditStyle.Hidden
                    || profileQuestion.EditStyle == ProfileQuestion.eEditStyle.MultiLine
                    || profileQuestion.EditStyle == ProfileQuestion.eEditStyle.SingleLine)
                {
                    continue;
                }

                count++;

                List<string> lChoices1 = new List<string>();
                List<string> lChoices2 = new List<string>();

                var answer1 = profileAnswers1.SingleOrDefault(a => a.Question.Id == profileQuestion.Id);
                var answer2 = profileAnswers2.SingleOrDefault(a => a.Question.Id == profileQuestion.MatchField);

                if (answer1 == null || answer2 == null)
                {
                    points += 0.5m;
                    continue;
                }

                if (profileQuestion.EditStyle == ProfileQuestion.eEditStyle.SingleChoiceRadio
                    || profileQuestion.EditStyle == ProfileQuestion.eEditStyle.SingleChoiceSelect)
                {
                    lChoices1.Add(answer1.Value);
                }
                else if (profileQuestion.EditStyle == ProfileQuestion.eEditStyle.MultiChoiceCheck
                         || profileQuestion.EditStyle == ProfileQuestion.eEditStyle.MultiChoiceSelect)
                {
                    foreach (string answer in answer1.Value.Split(':'))
                    {
                        lChoices1.Add(answer);
                    }
                }

                ProfileQuestion profileQuestion2 = ProfileQuestion.Fetch(profileQuestion.MatchField.Value);

                if (profileQuestion2.EditStyle == ProfileQuestion.eEditStyle.SingleChoiceRadio
                    || profileQuestion2.EditStyle == ProfileQuestion.eEditStyle.SingleChoiceSelect)
                {
                    lChoices2.Add(answer2.Value);
                }
                else if (profileQuestion2.EditStyle == ProfileQuestion.eEditStyle.MultiChoiceCheck
                         || profileQuestion2.EditStyle == ProfileQuestion.eEditStyle.MultiChoiceSelect)
                {
                    foreach (string answer in answer2.Value.Split(':'))
                    {
                        lChoices2.Add(answer);
                    }
                }

                var choices = lChoices1.Intersect(lChoices2);

                points += choices.Count() / (decimal)lChoices1.Count;
            }

            if (count != 0) return (int)(points / count * 100);
            else return -1;
        }