public async Task <Goal> AddGoal(string name, string description, List <CategoryType> categoryTypeCriteria, List <string> areaCriteria, List <Category> categoryCriteria,
                                         double limit)
        {
            var          id          = Guid.NewGuid();
            const string commandText =
                "INSERT INTO Goals (Id, Name, Description, \"Limit\", CategoryTypeCriteria, AreaCriteria, CategoryCriteria) " +
                "VALUES (@id, @name, @description, @limit, @categoryTypeCriteria, @areaCriteria, @categoryCriteria)";

            using (var conn = GetConnection())
                using (var command = new SQLiteCommand(conn)
                {
                    CommandText = commandText
                })
                {
                    command.Parameters.AddWithValue("@id", id);
                    command.Parameters.AddWithValue("@name", name);
                    command.Parameters.AddWithValue("@description", description);
                    command.Parameters.AddWithValue("@limit", limit);
                    command.Parameters.AddWithValue("@categoryTypeCriteria", JsonConvert.SerializeObject(categoryTypeCriteria));
                    command.Parameters.AddWithValue("@areaCriteria", JsonConvert.SerializeObject(areaCriteria));
                    command.Parameters.AddWithValue("@categoryCriteria", JsonConvert.SerializeObject(categoryCriteria.Select(x => x.Id).ToList()));

                    conn.Open();
                    await command.ExecuteNonQueryAsync();
                }

            GoalsUpdated?.Invoke(this, EventArgs.Empty);

            return(await GetGoal(id));
        }
        public async Task <Goal> UpdateGoal(Goal goal, string name, string description, List <CategoryType> categoryTypeCriteria, List <string> areaCriteria,
                                            List <Category> categoryCriteria, double limit)
        {
            const string commandText =
                "UPDATE Goals SET Name = @name, Description = @description, \"Limit\" = @limit, " +
                "CategoryTypeCriteria = @categoryTypeCriteria, AreaCriteria = @areaCriteria, CategoryCriteria = @categoryCriteria " +
                "WHERE Id = @id";

            using (var conn = GetConnection())
                using (var command = new SQLiteCommand(conn)
                {
                    CommandText = commandText
                })
                {
                    command.Parameters.AddWithValue("@id", goal.Id);
                    command.Parameters.AddWithValue("@name", name);
                    command.Parameters.AddWithValue("@description", description);
                    command.Parameters.AddWithValue("@limit", limit);
                    command.Parameters.AddWithValue("@categoryTypeCriteria", JsonConvert.SerializeObject(categoryTypeCriteria));
                    command.Parameters.AddWithValue("@areaCriteria", JsonConvert.SerializeObject(areaCriteria));
                    command.Parameters.AddWithValue("@categoryCriteria", JsonConvert.SerializeObject(categoryCriteria.Select(x => x.Id).ToList()));

                    conn.Open();
                    await command.ExecuteNonQueryAsync();
                }

            GoalsUpdated?.Invoke(this, EventArgs.Empty);

            return(await GetGoal(goal.Id));
        }
        public async Task DeleteGoal(Goal goal)
        {
            const string commandText = "DELETE FROM Goals WHERE Id = @id";

            using (var conn = GetConnection())
                using (var command = new SQLiteCommand(conn)
                {
                    CommandText = commandText
                })
                {
                    command.Parameters.AddWithValue("@id", goal.Id);
                    conn.Open();
                    await command.ExecuteNonQueryAsync();
                }
            GoalsUpdated?.Invoke(this, EventArgs.Empty);
        }