using Microsoft.Data.Sqlite;
using Project.Model;
namespace Project.Persistence;

public partial class SQLite
{
    //Method to save a new entry to SAVED_LOGINS
    public static void SaveEntry(string name, string pass, string mailUsername, string? note, string ownerUsername)
    {
        using var connection = new SqliteConnection($"Data Source={_dbPath}");
        connection.Open();
        using (var command = connection.CreateCommand())
        {
            command.Parameters.AddWithValue("@name", name);
            command.Parameters.AddWithValue("@pass", pass);
            command.Parameters.AddWithValue("@mail_username", mailUsername);
            command.Parameters.AddWithValue("@note", note ?? "");
            command.Parameters.AddWithValue("@owner", ownerUsername);
            
            command.CommandText =
                @"
        INSERT INTO SAVED_LOGINS (name, pass, mail_username, note, owner)
        VALUES (@name, @pass, @mail_username, @note, @owner);";
            command.ExecuteNonQuery();
        }
    }

}