public IActionResult SaveLecturer(int id, string firstname, string lastname, string mail, string notes, List <int> SkillIds)
        {
            LecturerBuilder builder = new LecturerBuilder(this.DatabaseContext, this.LecturerForId(id));

            builder.Firstname = firstname;
            builder.Lastname  = lastname;
            builder.Mail      = mail;
            builder.Notes     = notes;
            List <Skill> skillList = new List <Skill>();

            foreach (int eachId in SkillIds)
            {
                skillList.Add(this.DatabaseContext.SkillForId(eachId));
            }
            builder.Skills = skillList;
            builder.Save();
            return(RedirectToAction("Index", "Lecturer"));
        }
 public IActionResult Edit(int?id)
 {
     if (this.CurrentUserCanWrite())
     {
         Lecturer theLecturer;
         if (id.HasValue)
         {
             theLecturer = this.LecturerForId(id.Value);
         }
         else
         {
             LecturerBuilder lecturerBuilder = new LecturerBuilder(this.DatabaseContext);
             lecturerBuilder.Lastname  = "Nachname";
             lecturerBuilder.Firstname = "Vorname";
             lecturerBuilder.Mail      = "*****@*****.**";
             lecturerBuilder.Notes     = "Notizen";
             lecturerBuilder.Save();
             theLecturer = lecturerBuilder.Lecturer();
         }
         List <SelectListItem> theSkills = new List <SelectListItem>();
         foreach (Skill eachSkill in this.DatabaseContext.Skills)
         {
             SelectListItem listItem = new SelectListItem();
             listItem.Text     = eachSkill.Title;
             listItem.Value    = eachSkill.Id.ToString();
             listItem.Selected = theLecturer.HasSkill(eachSkill);
             theSkills.Add(listItem);
         }
         ViewBag.Skills = theSkills;
         return(View(theLecturer));
     }
     else
     {
         return(RedirectToAction("index"));
     }
 }