public ActionResult <Commentaar> Post(CommentaarDTO DTO)
 {
     try
     {
         Lid l = (Lid)_gebruikerRepository.GetBy(DTO.LidId);
         if (l == null)
         {
             return(BadRequest("Het opgegeven lid bestaat niet!"));
         }
         Lesmateriaal lesmat = _lesmateriaalRepository.GetBy(DTO.LesmateriaalId);
         if (lesmat == null)
         {
             return(BadRequest("Het opgegeven lesmateriaal bestaat niet!"));
         }
         Commentaar c = new Commentaar(l, lesmat, DTO.Tekst);
         _repo.Add(c);
         _repo.SaveChanges();
         return(CreatedAtAction(nameof(GetBy), new { id = c.Id }, c));
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Source);
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <Commentaar> Put(int id, CommentaarDTO DTO)
 {
     try
     {
         Lid l = (Lid)_gebruikerRepository.GetBy(DTO.LidId);
         if (l == null)
         {
             return(BadRequest("Het opgegeven lid bestaat niet!"));
         }
         Commentaar c = _repo.GetBy(id);
         if (c == null)
         {
             return(BadRequest("De Commentaar die u wenst te wijzigen bestaat nier"));
         }
         Lesmateriaal lesmat = _lesmateriaalRepository.GetBy(DTO.LesmateriaalId);
         if (lesmat == null)
         {
             return(BadRequest("Het opgegeven lesmateriaal bestaat niet!"));
         }
         c.Lid          = l;
         c.Lesmateriaal = lesmat;
         c.Tekst        = DTO.Tekst;
         _repo.Update(c);
         _repo.SaveChanges();
         return(CreatedAtAction(nameof(GetBy), new { id = c.Id }, c));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public ActionResult <CommentaarDTO> PostCommentaar(CommentaarDTO commentaardto)
        {
            Gebruiker  huidigeGebruiker = _gebruikerRepository.GetByEmail(User.Identity.Name);
            Commentaar commentaar       = new Commentaar(commentaardto.Tekst, commentaardto.CommentaarType, commentaardto.Datum, huidigeGebruiker.Id);

            _commentaarRepository.Add(commentaar);
            _commentaarRepository.SaveChanges();
            return(Ok());
        }