#pragma once
#include "User.h"
#include "Card.h"
#include "CardType.h"
#include "Utils/SqliteHelper.h"
#include "Utils/Utils.h"
enum class VerificationState
{
	InvalidCode,
	Verified,
	Expired,
	DifferentDevices,
	Disabled
};
class KNCenter
{
	SqliteHelper* sql;
public:
	KNCenter();
	~KNCenter();
	std::unique_ptr<User> CreateUser(std::string uname, std::string pwd, int level, int parent, UINT64 Authority, List<int> products);
	std::unique_ptr<User> GetUser(int id);
	std::unique_ptr<User> GetUser(std::string uname);
	List<User> GetAllUser();
	std::unique_ptr<Card> GetCard(int id);
	std::unique_ptr<Card> GetCard(std::string code);
	List<Card> GetAllCard();
	List<Card> GetAllCardForUser(int uid);
	std::unique_ptr<CardType> CreateCardType(std::string name, std::string prefix, UINT64 timeOfSeconds, std::string info, std::string file);
	std::unique_ptr<CardType> GetCardType(int id);
	std::unique_ptr<CardType> GetCardType(std::string name);
	List<CardType> GetAllCardType();
	std::string CreateCard(int uid, int type, std::string info);
	VerificationState CheckCard(std::string code, std::string hard);
	void DeleteCard(std::string code);
	void DisableCard(std::string code);
	void UpdateFile(std::string name, std::vector<BYTE> file);
	std::vector<BYTE> GetFile(std::string name);
};
