示例#1
0
        /// <summary>
        /// Update table to a db with offline property
        /// </summary>
        /// <typeparam name="TModel">Table or store to use</typeparam>
        /// <param name="rows">data to insert</param>
        /// <exception cref="ResponseException"></exception>
        /// <returns></returns>
        public async ValueTask <List <ResponseJsDb> > DbUpdateOffLine <TModel>([NotNull] List <TModel> rows)
        {
            try
            {
                List <dynamic> expanded = await AddOflineProperty.AddOfflineAsync(rows);

                if (Settings.EnableDebug)
                {
                    Console.WriteLine($"DbUpdateOffLine in modelL  = {Setup.Tables.GetTable<TModel>()}");
                }
                return(await DbUpdate(expanded));
            }

            catch (ResponseException ex)
            {
                if (Settings.EnableDebug)
                {
                    Console.WriteLine($"DbUpdateOffLine Model: {ex.StoreName} Error: {ex.Message} PayLoad: {ex.TransactionData}");
                }
                throw ex;
            }
            catch (Exception ex)
            {
                throw new ResponseException(nameof(DbUpdateOffLine), Setup.Tables.GetTable <TModel>(), ex.Message, ex);
            }
        }
        /// <summary>
        /// Insert int a table to a db with off-line property
        /// </summary>
        /// <typeparam name="TModel">Table or store to use</typeparam>
        /// <param name="rows">data to insert</param>
        /// <exception cref="ResponseException"></exception>
        /// <returns></returns>
        public async ValueTask <List <ResponseJsDb> > DbInserOffline <TModel>([NotNull] List <TModel> rows)
        {
            try
            {
                List <dynamic> expanded = await AddOflineProperty.AddOfflineAsync(rows);

                if (Settings.EnableDebug)
                {
                    Console.WriteLine($"DbInserOffline in model: {Setup.Tables.GetTable<TModel>()}");
                }
                return(await DbInsert(expanded));
            }
            catch (ResponseException ex)
            {
                if (Settings.EnableDebug)
                {
                    Console.WriteLine($"DbInsert Model: {Setup.Tables.GetTable<TModel>()} Error: {ex.Message}");
                }
                throw;
            }
            catch (Exception ex)
            {
                throw new ResponseException(nameof(DbInserOffline), Setup.Tables.GetTable <TModel>(), ex.Message, ex);
            }
        }