private void PoveziTagove()
        {
            if (txt_Tagovi.Text != String.Empty)
            {
                using (TriglavBL temp = new TriglavBL())
                {
                    string[] tags = txt_Tagovi.Text.Split(',');

                    foreach (var item in tags)
                    {
                        Data.EntityFramework.DAL.Tag tag = new Data.EntityFramework.DAL.Tag();
                        tag.Naziv = item.Trim();

                        if (temp.getTagByName(tag.Naziv) == null)
                        {
                            tag.DatumKreiranja = DateTime.Now;
                            temp.SaveTag(tag);
                        }
                        else
                        {
                            tag = temp.getTagByName(tag.Naziv);
                        }

                        if (temp.getPosts_TagsByIDS(post.id, tag.id) == null)
                        {
                            Data.EntityFramework.DAL.Posts_Tags posts_tags = new Data.EntityFramework.DAL.Posts_Tags();
                            posts_tags.PostID = post.id;
                            posts_tags.TagID  = tag.id;
                            temp.SavePosts_Tags(posts_tags);
                        }
                    }
                }
            }
        }
        private void PoveziTagove()
        {
            if (txt_Tagovi.Text != String.Empty)
            {
                using (TriglavBL temp = new TriglavBL())
                {
                    string[] tags = txt_Tagovi.Text.Split(',');

                    foreach (var item in tags)
                    {
                        Data.EntityFramework.DAL.Tag tag = new Data.EntityFramework.DAL.Tag();
                        tag.Naziv = item.Trim();

                        if (temp.getTagByName(tag.Naziv) == null)
                        {
                            tag.DatumKreiranja = DateTime.Now;
                            temp.SaveTag(tag);
                        }
                        else
                        {
                            tag = temp.getTagByName(tag.Naziv);
                        }

                        if (temp.getPosts_TagsByIDS(post.id, tag.id) == null)
                        {
                            Data.EntityFramework.DAL.Posts_Tags posts_tags = new Data.EntityFramework.DAL.Posts_Tags();
                            posts_tags.PostID = post.id;
                            posts_tags.TagID = tag.id;
                            temp.SavePosts_Tags(posts_tags);
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public void SavePosts_Tags(Posts_Tags post_tags)
 {
     context.Posts_Tags.Add(post_tags);
     context.SaveChanges();
 }