Ejemplo n.º 1
0
        public static DBO.Category GetCategory(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    var query = from category in bdd.T_Category
                                where category.id == id
                                select category;

                    if (query.Any())
                    {
                        return(new DBO.Category()
                        {
                            Id = query.First().id,
                            Name = query.First().name
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 2
0
        public static DBO.User GetUser(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    var query = from user in bdd.T_User
                                where user.id == id
                                select user;

                    if (query.Any())
                    {
                        return(new DBO.User()
                        {
                            Id = query.First().id,
                            Login = query.First().login,
                            Password = query.First().password,
                            Email = query.First().email,
                            Role = query.First().role
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 3
0
        public static List <DBO.Category> GetListCategory()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    List <DBO.Category> listCategories = new List <DBO.Category>();

                    var query = from category in bdd.T_Category
                                select category;

                    foreach (var element in query)
                    {
                        listCategories.Add(new DBO.Category()
                        {
                            Id   = element.id,
                            Name = element.name
                        });
                    }
                    return(listCategories);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 4
0
        public static List <DBO.Article> GetListArticle()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try {
                    List <DBO.Article> listArticles = new List <DBO.Article>();

                    var query = from article in bdd.T_Article
                                select article;

                    foreach (var element in query)
                    {
                        listArticles.Add(new DBO.Article()
                        {
                            Id         = element.id,
                            Title      = element.title,
                            Image      = element.image,
                            CategoryId = element.category_id,
                            Text       = element.text,
                            Date       = element.date,
                            Views      = element.views
                        });
                    }
                    return(listArticles);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    return(null);
                }
            }
        }
Ejemplo n.º 5
0
 public static bool UpdateComment(DBO.Comment comment)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Comment t_comment = bdd.T_Comment.Where(x => x.id == comment.Id).FirstOrDefault();
             if (t_comment != null)
             {
                 t_comment.id         = comment.Id;
                 t_comment.title      = comment.Title;
                 t_comment.text       = comment.Text;
                 t_comment.article_id = comment.ArticleId;
                 t_comment.user_id    = comment.UserId;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 6
0
 public static bool UpdateCategory(DBO.Category category)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Category t_category = bdd.T_Category.Where(x => x.id == category.Id).FirstOrDefault();
             if (t_category != null)
             {
                 t_category.id   = category.Id;
                 t_category.name = category.Name;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 7
0
 public static bool UpdateSocial(DBO.Social social)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Social t_social = bdd.T_Social.Where(x => x.id == social.Id).FirstOrDefault();
             if (t_social != null)
             {
                 t_social.id         = social.Id;
                 t_social.type       = social.Type;
                 t_social.account    = social.Account;
                 t_social.identifier = social.Identifier;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 8
0
        public static List <DBO.User> GetListUser()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    List <DBO.User> listUsers = new List <DBO.User>();

                    var query = from user in bdd.T_User
                                select user;

                    foreach (var element in query)
                    {
                        listUsers.Add(new DBO.User()
                        {
                            Id       = element.id,
                            Login    = element.login,
                            Password = element.password,
                            Email    = element.email,
                            Role     = element.role
                        });
                    }
                    return(listUsers);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 9
0
        public static List <DBO.Social> GetListSocial()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    List <DBO.Social> listSocials = new List <DBO.Social>();

                    var query = from social in bdd.T_Social
                                select social;

                    foreach (var element in query)
                    {
                        listSocials.Add(new DBO.Social()
                        {
                            Id         = element.id,
                            Type       = element.type,
                            Account    = element.account,
                            Identifier = element.identifier
                        });
                    }
                    return(listSocials);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 10
0
        public static DBO.SocialArticle GetSocialArticle(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    var query = from socialArticle in bdd.T_SocialArticle
                                where socialArticle.id == id
                                select socialArticle;

                    if (query.Any())
                    {
                        return(new DBO.SocialArticle()
                        {
                            Id = query.First().id,
                            Text = query.First().text,
                            Image = query.First().image,
                            SocialId = query.First().social_id
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 11
0
        public static DBO.Social GetSocial(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    var query = from social in bdd.T_Social
                                where social.id == id
                                select social;

                    if (query.Any())
                    {
                        return(new DBO.Social()
                        {
                            Id = query.First().id,
                            Type = query.First().type,
                            Account = query.First().account,
                            Identifier = query.First().identifier
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 12
0
        public static List <DBO.SocialArticle> GetListSocialArticle()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    List <DBO.SocialArticle> listSocialArticles = new List <DBO.SocialArticle>();

                    var query = from socialArticle in bdd.T_SocialArticle
                                select socialArticle;

                    foreach (var element in query)
                    {
                        listSocialArticles.Add(new DBO.SocialArticle()
                        {
                            Id       = element.id,
                            Text     = element.text,
                            Image    = element.image,
                            SocialId = element.social_id
                        });
                    }
                    return(listSocialArticles);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 13
0
 public static bool UpdateSocialArticle(DBO.SocialArticle socialArticle)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_SocialArticle t_socialArticle = bdd.T_SocialArticle.Where(x => x.id == socialArticle.Id).FirstOrDefault();
             if (t_socialArticle != null)
             {
                 t_socialArticle.id        = socialArticle.Id;
                 t_socialArticle.text      = socialArticle.Text;
                 t_socialArticle.image     = socialArticle.Image;
                 t_socialArticle.social_id = socialArticle.SocialId;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 14
0
 public static bool CreateArticle(DBO.Article article)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Article t_article = new T_Article()
             {
                 id          = article.Id,
                 title       = article.Title,
                 image       = article.Image,
                 category_id = article.CategoryId,
                 text        = article.Text,
                 date        = article.Date,
                 views       = article.Views
             };
             bdd.T_Article.Add(t_article);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 15
0
        public static DBO.Article GetArticle(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try {
                    var query = from article in bdd.T_Article
                                where article.id == id
                                select article;

                    if (query.Any())
                    {
                        return(new DBO.Article()
                        {
                            Id = query.First().id,
                            Title = query.First().title,
                            Image = query.First().image,
                            CategoryId = query.First().category_id,
                            Text = query.First().text,
                            Date = query.First().date,
                            Views = query.First().views
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 16
0
 public static bool UpdateArticle(DBO.Article article)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Article t_article = bdd.T_Article.Where(x => x.id == article.Id).FirstOrDefault();
             if (t_article != null)
             {
                 t_article.id          = article.Id;
                 t_article.title       = article.Title;
                 t_article.image       = article.Image;
                 t_article.category_id = article.CategoryId;
                 t_article.text        = article.Text;
                 t_article.date        = article.Date;
                 t_article.views       = article.Views;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 17
0
        public static DBO.Comment GetComment(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    var query = from comment in bdd.T_Comment
                                where comment.id == id
                                select comment;

                    if (query.Any())
                    {
                        return(new DBO.Comment()
                        {
                            Id = query.First().id,
                            Title = query.First().title,
                            Text = query.First().text,
                            ArticleId = query.First().article_id,
                            UserId = query.First().user_id
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 18
0
 public static bool UpdateUser(DBO.User user)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_User t_user = bdd.T_User.Where(x => x.id == user.Id).FirstOrDefault();
             if (t_user != null)
             {
                 t_user.id       = user.Id;
                 t_user.login    = user.Login;
                 t_user.password = user.Password;
                 t_user.email    = user.Email;
                 t_user.role     = user.Role;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 19
0
        public static DBO.Popularity GetPopularity(long id)
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    var query = from popularity in bdd.T_Popularity
                                where popularity.id == id
                                select popularity;

                    if (query.Any())
                    {
                        return(new DBO.Popularity()
                        {
                            Id = query.First().id,
                            Viewed = Convert.ToBoolean(query.First().viewed),
                            Liked = Convert.ToBoolean(query.First().liked),
                            ArticleId = query.First().article_id,
                            UserId = query.First().user_id
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 20
0
        public static List <DBO.Comment> GetListComment()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    List <DBO.Comment> listComments = new List <DBO.Comment>();

                    var query = from comment in bdd.T_Comment
                                select comment;

                    foreach (var element in query)
                    {
                        listComments.Add(new DBO.Comment()
                        {
                            Id        = element.id,
                            Title     = element.title,
                            Text      = element.text,
                            ArticleId = element.article_id,
                            UserId    = element.user_id
                        });
                    }
                    return(listComments);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 21
0
        public static List <DBO.Popularity> GetListPopularity()
        {
            using (IziWatchEntities bdd = new IziWatchEntities())
            {
                try
                {
                    List <DBO.Popularity> listPopularitys = new List <DBO.Popularity>();

                    var query = from popularity in bdd.T_Popularity
                                select popularity;

                    foreach (var element in query)
                    {
                        listPopularitys.Add(new DBO.Popularity()
                        {
                            Id        = element.id,
                            Viewed    = Convert.ToBoolean(element.viewed),
                            Liked     = Convert.ToBoolean(element.liked),
                            ArticleId = element.article_id,
                            UserId    = element.user_id
                        });
                    }
                    return(listPopularitys);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 22
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.º 23
0
 public static bool DeleteSocial(long id)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             bdd.T_Social.Remove(bdd.T_Social.Where(x => x.id == id).FirstOrDefault());
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 24
0
 public static bool CreateCategory(DBO.Category category)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Category t_category = new T_Category()
             {
                 id   = category.Id,
                 name = category.Name
             };
             bdd.T_Category.Add(t_category);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 25
0
 public static bool CreateSocial(DBO.Social social)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Social t_social = new T_Social()
             {
                 id         = social.Id,
                 type       = social.Type,
                 account    = social.Account,
                 identifier = social.Identifier
             };
             bdd.T_Social.Add(t_social);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 26
0
 public static bool CreateSocialArticle(DBO.SocialArticle socialArticle)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_SocialArticle t_socialArticle = new T_SocialArticle()
             {
                 id        = socialArticle.Id,
                 text      = socialArticle.Text,
                 image     = socialArticle.Image,
                 social_id = socialArticle.SocialId
             };
             bdd.T_SocialArticle.Add(t_socialArticle);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 27
0
 public static bool CreateComment(DBO.Comment comment)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Comment t_comment = new T_Comment()
             {
                 id         = comment.Id,
                 title      = comment.Title,
                 text       = comment.Text,
                 article_id = comment.ArticleId,
                 user_id    = comment.UserId
             };
             bdd.T_Comment.Add(t_comment);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 28
0
 public static bool CreateUser(DBO.User user)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_User t_user = new T_User()
             {
                 id       = user.Id,
                 login    = user.Login,
                 password = user.Password,
                 email    = user.Email,
                 role     = user.Role
             };
             bdd.T_User.Add(t_user);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 29
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);
         }
     }
 }