You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
// Author: Gockner, Simon
|
|
// Created: 2020-09-18
|
|
// Copyright(c) 2020 SimonG. All Rights Reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using GBase.Factories;
|
|
using GBase.Interfaces;
|
|
|
|
namespace Test.GBase.GBaseIntegrationTest
|
|
{
|
|
public class Model
|
|
{
|
|
private readonly IGBase _gBase;
|
|
|
|
public Model(IGBaseFactory gBaseFactory)
|
|
{
|
|
_gBase = gBaseFactory.Create(new Settings());
|
|
Items = new List<IItem>();
|
|
Groups = new List<IGroup>();
|
|
}
|
|
|
|
public List<IItem> Items { get; private set; }
|
|
public List<IGroup> Groups { get; private set; }
|
|
|
|
public async Task Initialize(CancellationToken cancellationToken)
|
|
{
|
|
await _gBase.Init("DB", Assembly.GetExecutingAssembly(), cancellationToken);
|
|
|
|
IGBaseTable<IItem> itemsTable = _gBase.GetTable<IItem>();
|
|
Items = itemsTable.Entries;
|
|
|
|
IGBaseTable<IGroup> groupsTable = _gBase.GetTable<IGroup>();
|
|
Groups = groupsTable.Entries;
|
|
}
|
|
|
|
public async Task AddItem(IItem item, CancellationToken cancellationToken)
|
|
{
|
|
Items.Add(item);
|
|
await _gBase.AddEntry(item, cancellationToken);
|
|
}
|
|
|
|
public async Task AddGroup(IGroup group, CancellationToken cancellationToken)
|
|
{
|
|
Groups.Add(group);
|
|
await _gBase.AddEntry(@group, cancellationToken);
|
|
}
|
|
}
|
|
} |