public static Common.Models.Tagging.TagCategory Create(Common.Models.Tagging.TagCategory model, Common.Models.Account.Users creator) { model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Tagging.TagCategory dbo = Mapper.Map <DBOs.Tagging.TagCategory>(model); using (IDbConnection conn = Database.Instance.GetConnection()) { conn.Execute("INSERT INTO \"tag_category\" (\"name\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Name, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); model.Id = conn.Query <DBOs.Tagging.TagCategory>("SELECT currval(pg_get_serial_sequence('tag_category', 'id')) AS \"id\"").Single().Id; } return(model); }
public static Common.Models.Tagging.TagCategory Create( Common.Models.Tagging.TagCategory model, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Tagging.TagCategory dbo = Mapper.Map <DBOs.Tagging.TagCategory>(model); conn = DataHelper.OpenIfNeeded(conn); if (conn.Execute("INSERT INTO \"tag_category\" (\"name\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Name, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo) > 0) { model.Id = conn.Query <DBOs.Tagging.TagCategory>("SELECT currval(pg_get_serial_sequence('tag_category', 'id')) AS \"id\"").Single().Id; } DataHelper.Close(conn, closeConnection); return(model); }