Beispiel #1
0
        public void Delete()
        {
            TagArticle.DeleteConnectedWithArticle(Id);
            var sqlCmd = $"delete from articles where id = {Id}";
            var cmd    = new NpgsqlCommand(sqlCmd, DBConnect.Connection);

            cmd.ExecuteNonQuery();
            cmd.Dispose();
        }
Beispiel #2
0
        public void Create(int userId, List <int> tagsIds)
        {
            UserId = userId;
            var insertCmd = $"insert into articles(latin_header, russian_header, body, author_user_id) values('{HeaderLatin}', '{Header}', '{Body}', '{UserId}') returning id";
            var cmd       = new NpgsqlCommand(insertCmd, DBConnect.Connection);
            var reded     = cmd.ExecuteScalar();

            Id = (int)reded;
            cmd.Dispose();
            foreach (var x in tagsIds)
            {
                var tagArticle = new TagArticle {
                    ArticleId = Id, TagId = x
                };
                tagArticle.Create();
            }
        }