/* * This method creates a table and inserts it into Uniconta. */ private async void CreateTableBtn_Click(object sender, RoutedEventArgs e) { // Acquire CRUD API var crud = UnicontaManager.GetInstance().CrudAPI; // Initialize table header var tableHeader = new TableHeaderClient { _MenuPosition = 1, // Customer Menu _Name = "APICourse20190410", // Name of the Table (for the backend) _Prompt = "API-Course 091018", // Promp (Name in the menu) _UserDefinedId = 1928, // Some arbitrary user defined ID I have assigned. }; // Insert table header var result = await crud.Insert(tableHeader); if (result != ErrorCodes.Succes) { MessageBox.Show("Unable to insert table header. Error: " + result.ToString(), "Error"); return; } MessageBox.Show("Succesfully inserted table header into Uniconta.\nName: " + tableHeader._Name + "\nPrompt: " + tableHeader._Prompt + "\nUserDefinedID: " + tableHeader._UserDefinedId, "Succes"); CurrentTableHeader = tableHeader; }
public static UnicontaManager GetInstance() { if (_instance == null) { _instance = new UnicontaManager(); } return(_instance); }
private async void LoginBtn_Click(object sender, RoutedEventArgs e) { var username = UsernameTextbox.Text; var password = PasswordTextbox.Password; var loggedIn = await UnicontaManager.GetInstance().Login(username, password); if (!loggedIn) { MessageBox.Show("Failed to log in.", "Error"); return; } new LoggedInWindow().Show(); this.Close(); }
/* * This method inserts fields into a table in Uniconta. */ private async void PopulateTable_Click(object sender, RoutedEventArgs e) { // Acquire CRUD API var crud = UnicontaManager.GetInstance().CrudAPI; // Initialize new fields var newFields = new List <TableField> { // Foreign Key to Employee Table new TableField { _RefTable = "Employee", _Prompt = "Employee", _Name = "Employee", _FieldType = CustomTypeCode.String, }, // String field naming school of employee new TableField { _Name = "School", _Prompt = "School", _FieldType = CustomTypeCode.String, }, }; // Loop over newFields and set their master foreach (var field in newFields) { field.SetMaster(CurrentTableHeader); } // Insert newFields in bulk var result = await crud.Insert(newFields); if (result != ErrorCodes.Succes) { MessageBox.Show("Unable to insert fields into table. Error: " + result.ToString(), "Error"); return; } var msg = String.Format("Succesfully inserted {0} fields into table {1}", newFields.Count, CurrentTableHeader.Name); MessageBox.Show(msg, "Succes"); }
public MainWindow() { InitializeComponent(); UnicontaManager.GetInstance().Initialize(); }