private Transport RunOperation(ICrudOperations entity, User user, DbConcurencyUpdateOptions concurencyUpdateOptions, CrudOperation operation, Filter filter) { Transport result = new Transport(); switch (operation) { case CrudOperation.Add: result.Single = entity.Add(concurencyUpdateOptions, user); break; case CrudOperation.Update: result.Single = entity.Update(concurencyUpdateOptions, user); break; case CrudOperation.Delete: result.Single = entity.Delete(concurencyUpdateOptions, user); break; case CrudOperation.Select: Type type = entity.GetType(); var ob = (ICrudOperations)Activator.CreateInstance(type); result.Collection = ob.Select(filter, user); break; } return(result); }
/// <summary> /// Loads docset with docs cast per Query(T) or empty enum /// </summary> public static IEnumerable <TDoc> LoadEnumerable <TDoc>(this ICrudOperations operations, Query <TDoc> query) where TDoc : Doc { if (operations == null || query == null) { throw new AzosException(StringConsts.ARGUMENT_ERROR + "LoadEnumerable(ICRUDOperations==null | query==null)"); } return(operations.LoadOneRowset(query).AsEnumerableOf <TDoc>()); }
/// <summary> /// Loads one document cast per Query(T) or null /// </summary> public static TDoc LoadDoc <TDoc>(this ICrudOperations operations, Query <TDoc> query) where TDoc : Doc { if (operations == null || query == null) { throw new AzosException(StringConsts.ARGUMENT_ERROR + "LoadDoc(ICRUDOperations==null | query==null)"); } return(operations.LoadOneDoc(query) as TDoc); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ICrudOperations operations = GlobalConfig.Inject(); MainWindow mw = new MainWindow(operations); mw.Show(); }
/// <summary> /// Async version - loads docset with rows cast per Query(T) or empty enum /// </summary> public static async Task <IEnumerable <TDoc> > LoadEnumerableAsync <TDoc>(this ICrudOperations operations, Query <TDoc> query) where TDoc : Doc { if (operations == null || query == null) { throw new AzosException(StringConsts.ARGUMENT_ERROR + "LoadEnumerableAsync(ICRUDOperations==null | query==null)"); } var got = await operations.LoadOneRowsetAsync(query).ConfigureAwait(false); return(got.AsEnumerableOf <TDoc>()); }
public MainWindow(ICrudOperations operations) { InitializeComponent(); Operations = operations; }
public Transport MakeOperation(ICrudOperations entity, User user, DbConcurencyUpdateOptions concurencyUpdateOptions, CrudOperation operation, Filter filter) { AuthenticateUser(user); return(RunOperation(entity, user, concurencyUpdateOptions, operation, filter)); }
public UserOperations(Func <IDbConnection> connectionFactory, ICrudOperations <TodoItem> todoItemOperations) { ConnectionFactory = connectionFactory; TodoItemOperations = todoItemOperations; }