Exemple #1
0
        public ActionResult AddMyCompetences(competence competence)
        {
            FullResumeOperations resumeOperations = new FullResumeOperations();
            var fullResume = resumeOperations.GetFullResumeById(competence.resume_id);

            fullResume.SelectedCompetenceId = competence.competence_id;

            if (fullResume.MyCompetences.Count == 0)
            {
                for (int i = 0; i < fullResume.Competences.Count; i++)
                {
                    if (fullResume.Competences[i].competence_id == fullResume.SelectedCompetenceId)
                    {
                        fullResume.MyCompetences.Add(fullResume.Competences[i]);
                        int lastComp = fullResume.MyCompetences.Count;
                        lastComp--;
                        resumeOperations.AddMyCompetences(fullResume.MyCompetences[lastComp].competence_id, fullResume.Resume_id);
                        resumeOperations.GetTechnologyList(fullResume);

                        int num = db.SaveChanges();
                        return(Json(num));
                    }
                }
            }
            else
            {
                foreach (var comp in fullResume.MyCompetences)
                {
                    if (comp.competence_id == fullResume.SelectedCompetenceId)
                    {
                        // Visa meddelande "Du har redan lagt till den här kompetensen."
                    }
                    else
                    {
                        for (int i = 0; i < fullResume.Competences.Count; i++)
                        {
                            if (fullResume.Competences[i].competence_id == fullResume.SelectedCompetenceId)
                            {
                                fullResume.MyCompetences.Add(fullResume.Competences[i]);
                                int lastComp = fullResume.MyCompetences.Count;
                                lastComp--;
                                resumeOperations.AddMyCompetences(fullResume.MyCompetences[lastComp].competence_id, fullResume.Resume_id);
                                resumeOperations.GetTechnologyList(fullResume);
                                int num = db.SaveChanges();
                                return(Json(num));
                            }
                        }
                    }
                }
            }

            return(View(fullResume));
        }