Merge from totem

This commit is contained in:
2015-10-21 21:23:48 +02:00
parent debd1c32a7
commit c466aed242
64 changed files with 3821 additions and 172 deletions

View File

@ -442,6 +442,8 @@ namespace Npgsql.Web.Blog
private long GetTagId (string tagname)
{
if (tagname == null)
throw new NullReferenceException ("This tag name is null");
long id = 0;
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
@ -455,6 +457,8 @@ namespace Npgsql.Web.Blog
private long GetOrCreateTagId (string tagname)
{
if (tagname == null)
throw new NullReferenceException ("This tag name is null");
long id = 0;
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) {
try {
@ -468,7 +472,6 @@ namespace Npgsql.Web.Blog
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "INSERT INTO public.tag(name) VALUES (:name) RETURNING _id";
cmd.Parameters.AddWithValue ("name", tagname);
cnx.Open ();
id = (long)cmd.ExecuteScalar ();
}
}

View File

@ -57,7 +57,8 @@ namespace Npgsql.Web.Blog
"WHERE \n" +
" tagged.postid = blog._id AND \n" +
" tag._id = tagged.tagid AND \n" +
" public.tag.name = :name";
" blog.visible = TRUE AND \n" +
" public.tag.name = :name";
cmd.Parameters.AddWithValue ("name", tagname);
cnx.Open ();
using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) {