コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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>());
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            ICrudOperations operations = GlobalConfig.Inject();

            MainWindow mw = new MainWindow(operations);

            mw.Show();
        }
コード例 #5
0
        /// <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>());
        }
コード例 #6
0
 public MainWindow(ICrudOperations operations)
 {
     InitializeComponent();
     Operations = operations;
 }
コード例 #7
0
        public Transport MakeOperation(ICrudOperations entity, User user, DbConcurencyUpdateOptions concurencyUpdateOptions, CrudOperation operation, Filter filter)
        {
            AuthenticateUser(user);

            return(RunOperation(entity, user, concurencyUpdateOptions, operation, filter));
        }
コード例 #8
0
 public UserOperations(Func <IDbConnection> connectionFactory, ICrudOperations <TodoItem> todoItemOperations)
 {
     ConnectionFactory  = connectionFactory;
     TodoItemOperations = todoItemOperations;
 }