Example #1
0
        /// <summary>
        /// Adds a new record/object to the specified store
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="recordToAdd">An instance of StoreRecord that provides the store name and the data to add</param>
        /// <returns></returns>
        public async Task <Guid> AddRecord <T>(StoreRecord <T> recordToAdd, Action <BlazorDbEvent> action = null)
        {
            var trans = GenerateTransaction(action);

            try
            {
                recordToAdd.DbName = DbName;
                await CallJavascriptVoid(IndexedDbFunctions.ADD_ITEM, trans, recordToAdd);
            }
            catch (JSException e)
            {
                RaiseEvent(trans, true, e.Message);
            }
            return(trans);
        }
Example #2
0
        /// <summary>
        /// Puts a new record/object to the specified store
        /// Waits for response
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="recordToPut">An instance of StoreRecord that provides the store name and the data to put</param>
        /// <returns></returns>
        public async Task <BlazorDbEvent> PutRecordAsync <T>(StoreRecord <T> recordToPut)
        {
            var trans = GenerateTransaction();

            try
            {
                recordToPut.DbName = DbName;
                await CallJavascriptVoid(IndexedDbFunctions.PUT_ITEM, trans.trans, recordToPut);
            }
            catch (JSException e)
            {
                RaiseEvent(trans.trans, true, e.Message);
            }
            return(await trans.task);
        }