Ejemplo n.º 1
0
        public async Task TryDelete(int id, Action <string> onSuccess, Action <Exception, string> onFail, CascadingAppStateProvider state)
        {
            try
            {
                if (await _onlineState.IsOnline())
                {
                    ClassRequestDelete  req = new() { Id = id };
                    ClassResponseDelete ret = await _classService.DeleteAsync(req);

                    if (!ret.Success)
                    {
                        throw new Exception(RequestCodes.FIVE_ZERO_ZERO);
                    }
                }

                if (state.AppState.UseIndexedDB)
                {
                    await _indexedDBManager.OpenDb();

                    await _indexedDBManager.ClearStore("Blobs");
                }

                onSuccess(RequestCodes.TWO_ZERO_ZERO);
            }
            catch (Exception e)
            {
                onFail(e, RequestCodes.FIVE_ZERO_ZERO);
            }
        }
Ejemplo n.º 2
0
        public async Task TryDelete(int id, Action <string> onSuccess, Action <Exception, string> onFail, CascadingAppStateProvider state)
        {
            try
            {
                if (state.AppState.UseIndexedDB)
                {
                    if (await _onlineState.IsOnline())
                    {
                        UserRequestDelete  req = new() { Id = id };
                        UserResponseDelete ret = await _userService.DeleteAsync(req);

                        if (!ret.Success)
                        {
                            onFail(new Exception(RequestCodes.FIVE_ZERO_THREE), ret.Status);
                            return;
                        }

                        await _indexedDBManager.OpenDb();

                        await _indexedDBManager.ClearStore("Blobs");

                        onSuccess(ret.Status);
                        return;
                    }
                    else
                    {
                        onFail(new Exception(RequestCodes.FIVE_ZERO_FOUR), " Could Not Delete, Please Try Again Later");
                        return;
                    }
                }
                else if (await _onlineState.IsOnline())
                {
                    UserRequestDelete  req = new() { Id = id };
                    UserResponseDelete ret = await _userService.DeleteAsync(req);

                    if (!ret.Success)
                    {
                        onFail(new Exception(RequestCodes.FIVE_ZERO_THREE), ret.Status);
                        return;
                    }

                    onSuccess(ret.Status);
                    return;
                }
            }
            catch (Exception e)
            {
                onFail(e, RequestCodes.FIVE_ZERO_ZERO);
            }
        }