public void AddChannels(string user, string channels)
 {
     try
     {
         using (BD.AtomicRssDatabaseContainer context = new BD.AtomicRssDatabaseContainer())
         {
             XmlReader       read  = XmlReader.Create(channels);
             SyndicationFeed sfeed = SyndicationFeed.Load(read);
             read.Close();
             BD.Channels chan = (from el in context.ChannelsSet where el.Title == sfeed.Title.Text select el).FirstOrDefault();
             BD.Users    u    = (from el in context.UsersSet where el.Email == user select el).FirstOrDefault();
             if (chan != null && u != null)
             {
                 chan.Users.Add(u);
             }
             else if (u != null && chan == null)
             {
                 chan             = new BD.Channels();
                 chan.Author      = "Unkwon";
                 chan.Language    = (sfeed.Language == null) ? ("Uk") : (sfeed.Language);
                 chan.Description = (sfeed.Description.Text.Length > 256) ? (sfeed.Description.Text.Substring(0, 256)) : (sfeed.Description.Text);
                 chan.Title       = sfeed.Title.Text;
                 chan.Date        = DateTime.Now; // Corrige la plus part des problemes de loading de nouveau channel
                 chan.Link        = channels;
                 context.ChannelsSet.AddObject(chan);
                 //foreach (SyndicationItem article in sfeed.Items)
                 //{
                 //    BD.Articles a = new BD.Articles();
                 //    a.Date = article.PublishDate.DateTime;
                 //    a.Title = article.Title.Text;
                 //    a.Description = article.Summary.Text;
                 //    a.GUID = "0000";
                 //    a.Link = article.Id;
                 //    chan.Articles.Add(a);
                 //    context.ArticlesSet.AddObject(a);
                 //}
                 chan.Users.Add(u);
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.StackTrace);
     }
 }
 public void DestroyChannelsRelation(int id_channels)
 {
     try
     {
         using (BD.AtomicRssDatabaseContainer context = new BD.AtomicRssDatabaseContainer())
         {
             BD.Channels channel = (from el in context.ChannelsSet where el.Id == id_channels select el).FirstOrDefault();
             if (channel != null)
             {
                 channel.Users.Clear();
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
 public void RemoveChannelsFromUser(string user, int id_channels)
 {
     try
     {
         using (BD.AtomicRssDatabaseContainer context = new BD.AtomicRssDatabaseContainer())
         {
             BD.Users    u    = (from el in context.UsersSet where el.Email == user select el).FirstOrDefault();
             BD.Channels chan = (from el in context.ChannelsSet where id_channels == el.Id select el).FirstOrDefault();
             if (u != null && chan != null)
             {
                 chan.Users.Remove(u);
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }