public static int Create(User.User user, ProjectProduct product) { var expiryAt = DateTime.UtcNow.AddHours(product.duration_hours); return(ExecuteScalarInt( @"INSERT INTO user_owned_products(guid, user_id, product_id, expiry_at, updated_at) VALUES (@guid, @user_id, @product_id, @expiry_at, CURRENT_TIMESTAMP); SELECT currval('user_owned_products_id_seq');" , new { guid = Guid.NewGuid().ToString(), user_id = user.id, product_id = product.id, expiry_at = expiryAt } )); }
public static int UsersCount(ProjectProduct product) => QueryInt( "SELECT COUNT(*) FROM user_owned_products WHERE product_id = @product_id", new { product_id = product.id } );