/// <summary>
        /// 根据ID主键删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <bool> Delete(string id)
        {
            try
            {
                await _iAttachmentRepository.DeleteAsync(id);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        public async Task DeleteAttachmentDataAsync(string attachmentId)
        {
            await _attachmentRepository.DeleteAsync(attachmentId);

            CachedCiphers = null;
            _appSettingsService.ClearCiphersCache = true;
        }
        public async Task DeleteAttachmentAsync(int id)
        {
            var attachment = await _attachmentRepository.GetByIdAsync(id);

            await _attachmentRepository.DeleteAsync(attachment);

            File.Delete(attachment.Path);
        }
Beispiel #4
0
        public async Task <ApiResult> DeleteAttachmentAsync(Login login, string attachmentId)
        {
            var response = await _cipherApiRepository.DeleteAttachmentAsync(login.Id, attachmentId);

            if (response.Succeeded)
            {
                await _attachmentRepository.DeleteAsync(attachmentId);
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.Forbidden ||
                     response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                MessagingCenter.Send(Application.Current, "Logout", (string)null);
            }

            return(response);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IResultModel> Delete(Guid id)
        {
            var entity = await _repository.GetAsync(id);

            if (entity == null)
            {
                return(ResultModel.NotExists);
            }

            if (await _repository.DeleteAsync(id))
            {
                return(ResultModel.Success());
            }

            return(ResultModel.Failed());
        }
Beispiel #6
0
        public async Task <bool> DeleteAsync(Models.Attachment model)
        {
            var success = await _attachmentRepository.DeleteAsync(model.Id);

            if (success)
            {
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("Deleted attachment '{0}' with id {1}",
                                           model.Name, model.Id);
                }

                CancelTokens(model);
            }

            return(success);
        }
        public async Task <ResponseLogic> DeleteAsync(int attachmentId)
        {
            var attachment = await _repository.FindAsync(attachmentId);

            if (attachment is null)
            {
                return(ResponseLogic.NOT_FOUND);
            }

            var success = await _repository.DeleteAsync(attachmentId);

            if (success)
            {
                return(ResponseLogic.SUCCESS);
            }
            else
            {
                return(ResponseLogic.ERROR_DELETING);
            }
        }
Beispiel #8
0
        public async Task <IResultModel> Delete(Guid id)
        {
            var result = await _repository.DeleteAsync(id);

            return(ResultModel.Result(result));
        }
Beispiel #9
0
        public async Task <bool> SyncCipherAsync(string id)
        {
            if (!_authService.IsAuthenticated)
            {
                return(false);
            }

            SyncStarted();

            var cipher = await _cipherApiRepository.GetByIdAsync(id).ConfigureAwait(false);

            if (!CheckSuccess(cipher))
            {
                return(false);
            }

            try
            {
                switch (cipher.Result.Type)
                {
                case Enums.CipherType.Login:
                    var loginData = new LoginData(cipher.Result, _authService.UserId);
                    await _loginRepository.UpsertAsync(loginData).ConfigureAwait(false);

                    var localAttachments = (await _attachmentRepository.GetAllByLoginIdAsync(loginData.Id)
                                            .ConfigureAwait(false));

                    if (cipher.Result.Attachments != null)
                    {
                        foreach (var attachment in cipher.Result.Attachments)
                        {
                            var attachmentData = new AttachmentData(attachment, loginData.Id);
                            await _attachmentRepository.UpsertAsync(attachmentData).ConfigureAwait(false);
                        }
                    }

                    if (localAttachments != null)
                    {
                        foreach (var attachment in localAttachments
                                 .Where(a => !cipher.Result.Attachments.Any(sa => sa.Id == a.Id)))
                        {
                            try
                            {
                                await _attachmentRepository.DeleteAsync(attachment.Id).ConfigureAwait(false);
                            }
                            catch (SQLite.SQLiteException) { }
                        }
                    }
                    break;

                default:
                    SyncCompleted(false);
                    return(false);
                }
            }
            catch (SQLite.SQLiteException)
            {
                SyncCompleted(false);
                return(false);
            }

            SyncCompleted(true);
            return(true);
        }
Beispiel #10
0
        public async Task DeleteAttachmentDataAsync(string attachmentId)
        {
            await _attachmentRepository.DeleteAsync(attachmentId);

            CachedCiphers = null;
        }
 public async Task <int> DeleteAsync(int simCardId, int userId, string username)
 {
     return(await _repository.DeleteAsync(simCardId, userId, username));
 }