public ActionResult Edit(int? id)
        {
            CandidatesService candidatesService = new CandidatesService();
            CandidateEditVM model = new CandidateEditVM();
            Candidate candidate;

            if (!id.HasValue)
            {
                candidate = new Candidate();
            }
            else
            {
                candidate = candidatesService.GetById(id.Value);
                if (candidate == null)
                {
                    return RedirectToAction("List");
                }
            }

            model.Id = candidate.Id;
            model.FirstName = candidate.FirstName;
            model.MiddleName = candidate.MiddleName;
            model.LastName = candidate.LastName;
            model.Email = candidate.Email;
            model.Notes = candidate.Notes;
            model.UsedTechnologies = candidatesService.GetSelectedUsedTechnologies(candidate.UsedTechnologies);
            model.ProgrammingLanguages = candidatesService.GetSelectedProgrammingLanguages(candidate.ProgrammingLanguages);
            return View(model);
        }
        public ActionResult Edit()
        {
            CandidatesService candidatesService = new CandidatesService();
            CandidateEditVM model = new CandidateEditVM();
            TryUpdateModel(model);

            Candidate candidate;
            if (model.Id == 0)
            {
                candidate = new Candidate();
            }
            else
            {
                candidate = candidatesService.GetById(model.Id);
                if (candidate == null)
                {
                    return RedirectToAction("List");
                }
            }

            if (!ModelState.IsValid)
            {
                model.UsedTechnologies = candidatesService.GetSelectedUsedTechnologies(candidate.UsedTechnologies);
                model.ProgrammingLanguages = candidatesService.GetSelectedProgrammingLanguages(candidate.ProgrammingLanguages);
                return View(model);
            }

            candidate.Id = model.Id;
            candidate.FirstName = model.FirstName;
            candidate.MiddleName = model.MiddleName;
            candidate.LastName = model.LastName;
            candidate.Email = model.Email;
            candidate.Notes = model.Notes;
            candidatesService.SetSelectedUsedTechnologies(candidate, model.SelectedUsedTechnologies);
            candidatesService.SetSelectedProgrammingLanguages(candidate, model.SelectedProgrammingLanguages);

            candidatesService.Save(candidate);
            return RedirectToAction("List");
        }