public void AssignTags(List <string> tags, int id)
        {
            TagProject.RemoveRange(TagProject.Where(t => t.ProjectId == id));

            foreach (var tag in tags)
            {
                if (Tags.Any(t => t.Naam.ToLower() == tag.ToLower().Trim()))
                {
                    //Projecten
                    //    .Include(x => x.TagProjects).ThenInclude(x => x.Tag)
                    //    .SingleOrDefault(p => p.Id == id)
                    //    .TagProjects.Add(new TagProject { TagId = Tags.SingleOrDefault(t => t.Naam.ToLower() == tag.ToLower().Trim()).Id, ProjectId = Projecten.SingleOrDefault(p => p.Id == id).Id });
                    TagProject.Add(new TagProject {
                        TagId = Tags.SingleOrDefault(t => t.Naam.ToLower() == tag.ToLower().Trim()).Id, ProjectId = Projecten.SingleOrDefault(p => p.Id == id).Id
                    });
                }
                else
                {
                    Tag newTag = new Tag {
                        Naam = tag.Trim().ToLower()
                    };
                    Tags.Add(newTag);
                    //Projecten
                    //    .Include(x=>x.TagProjects).ThenInclude(x=>x.Tag)
                    //    .SingleOrDefault(p => p.Id == id)
                    //    .TagProjects.Add(new TagProject { Tag = new Tag { Naam = tag.ToLower().Trim() }, ProjectId = Projecten.SingleOrDefault(p => p.Id == id).Id });
                    TagProject.Add(new TagProject {
                        Tag = new Tag {
                            Naam = tag.ToLower().Trim()
                        }, ProjectId = Projecten.SingleOrDefault(p => p.Id == id).Id
                    });
                }
            }
            this.SaveChanges();
        }
 public Project GetProject(int id)
 {
     return(Projecten
            .Include(x => x.Status)
            .Include(p => p.TagProjects).ThenInclude(p => p.Tag)
            .SingleOrDefault(p => p.Id == id));
 }
        public void Delete(int id)
        {
            var project = Projecten.SingleOrDefault(x => x.Id == id);

            if (project != null)
            {
                Projecten.Remove(project);
                this.SaveChanges();
            }
        }
        public void Update(int id, Project updatedProject)
        {
            var project = Projecten.SingleOrDefault(p => p.Id == id);

            if (project != null)
            {
                project.Titel        = updatedProject.Titel;
                project.Beschrijving = updatedProject.Beschrijving;
                project.Status       = updatedProject.Status;
            }
            this.SaveChanges();
        }
 public Project Insert(Project project)
 {
     Projecten.Add(project);
     this.SaveChanges();
     return(project);
 }
 public IEnumerable <Project> GetProjecten()
 {
     return(Projecten
            .Include(x => x.Status)
            .Include(x => x.TagProjects).ThenInclude(x => x.Tag));
 }