Ejemplo n.º 1
0
 public static bool UpdatePopularity(DBO.Popularity popularity)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Popularity t_popularity = bdd.T_Popularity.Where(x => x.id == popularity.Id).FirstOrDefault();
             if (t_popularity != null)
             {
                 t_popularity.id         = popularity.Id;
                 t_popularity.viewed     = Convert.ToByte(popularity.Viewed);
                 t_popularity.liked      = Convert.ToByte(popularity.Liked);
                 t_popularity.article_id = popularity.ArticleId;
                 t_popularity.user_id    = popularity.UserId;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 2
0
 public static bool CreatePopularity(DBO.Popularity popularity)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Popularity t_popularity = new T_Popularity()
             {
                 id         = popularity.Id,
                 viewed     = Convert.ToByte(popularity.Viewed),
                 liked      = Convert.ToByte(popularity.Liked),
                 article_id = popularity.ArticleId,
                 user_id    = popularity.UserId
             };
             bdd.T_Popularity.Add(t_popularity);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }