Esempio n. 1
0
        protected virtual async Task DeleteSetting(Setting setting, bool clearCache)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            await _settingRepository.DeleteAsync(setting);

            //cache
            if (clearCache)
            {
                _cacheManager.RemoveByPattern(SETTINGS_PATTERN_KEY);
            }
        }
Esempio n. 2
0
        public async Task <ApiResult <DeleteResult> > Delete([FromRoute] string id)
        {
            var objectId           = ParseCertId(id);
            var deleteCourseResult = await _repository.DeleteManyAsync <Course>(CourseController.CollectionName, x => x.CertificationId == id);

            return(await _repository.DeleteAsync <Certification>(CollectionName, x => x.Id == objectId));
        }
Esempio n. 3
0
        public async Task RevokeOneAsync(RefreshToken token)
        {
            //token.RevokedAt = DateTime.Now;

            //await _repository.UpdateAsync(token);
            await _repository.DeleteAsync(token.Guid);
        }
Esempio n. 4
0
        public async Task DeleteAsync(string id)
        {
            if (!await _cityRepository.AnyAsync(city => city.Id == id))
            {
                throw new ItemNotFoundException(id);
            }

            await _cityRepository.DeleteAsync(id);
        }
        public async Task DeletePost(Guid postId)
        {
            var item = await _blogStatsItemRepository.GetAsync(c => c.PostId == postId);

            if (item != null)
            {
                await _blogStatsItemRepository.DeleteAsync(item.Id);
            }
        }
Esempio n. 6
0
        public async Task DeleteAsync(string id)
        {
            if (!await _districtRepository.AnyAsync(district => district.Id == id))
            {
                throw new ItemNotFoundException(id);
            }

            await _districtRepository.DeleteAsync(id);
        }
Esempio n. 7
0
        public async Task Delete(string guid)
        {
            var qa = _qpRepository.Get(o => o.Guid == guid).First();

            _qpRepository.Delete(qa);
            await _mongo.DeleteAsync <Reply>(o => o.PostGuid == guid);

            await _mongo.DeleteFileByPostGuidAsync(guid);

            _qpRepository.SaveChanges();
        }
Esempio n. 8
0
        public async Task RemoveAsync(Guid id, Guid courseId)
        {
            var course = await _courseRepository.GetAsync(courseId);

            var courseModule = await _repository.GetAsync(id);

            course.Modules.ToList().Remove(courseModule.Id);
            await _courseRepository.UpdateAsync(course);

            await _repository.DeleteAsync(id);
        }
        public async Task RemoveAsync(Guid id, Guid moduleId)
        {
            var module = await _moduleRepository.GetAsync(moduleId);

            var episode = await _repository.GetAsync(id);

            module.Episodes.ToList().Remove(episode.Id);
            await _repository.DeleteAsync(id);

            await _moduleRepository.UpdateAsync(module);
        }
Esempio n. 10
0
        public async Task HandleLogic()
        {
            User savedUser = await _mongoRepository.SaveAsync(new User { Name = "ali", Age = 20, Addresses = new List <string> {
                                                                             "Tehran", "Shiraz"
                                                                         } });

            User takenUser = await _mongoRepository.GetByIdAsync(savedUser.Id);

            ICollection <User> users = await _mongoRepository.FindAllAsync(u => u.Name == "ali");

            await _mongoRepository.DeleteAsync(takenUser.Id);
        }
Esempio n. 11
0
        public async Task <bool> DeleteOrder(string OrderId)
        {
            try
            {
                await _repository.DeleteAsync <Order>(e => e.Id == OrderId);

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Delete Animal Failed: {e.Message}");
                return(false);
            }
        }
Esempio n. 12
0
        public virtual async Task DeleteLocalizationResource(string name, string languageCultureCode)
        {
            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(languageCultureCode))
            {
                return;
            }

            var localizationResource = _localizationResourceRepository.Find(lr => lr.Name == name && lr.LanguageCultureCode == languageCultureCode);

            if (localizationResource != null)
            {
                await _localizationResourceRepository.DeleteAsync(localizationResource);
            }
        }
Esempio n. 13
0
        public async Task <bool> DeleteAnimal(string id)
        {
            try
            {
                await _repository.DeleteAsync <LiveAnimal>(e => e.Id == id);

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"GetAnimalDetails Failed: {e.Message}");
                return(false);
            }
        }
        public async Task <Result> Handle(DeleteContractCommand request, CancellationToken cancellationToken)
        {
            var contract = await _contractRepository.GetAsync(request.Id, cancellationToken);

            if (contract is null)
            {
                return(Result.Failed(new NotFoundObjectResult(new ApiMessage(ResponseMessage.ContractNotFound))));
            }



            await _contractRepository.DeleteAsync(request.Id);


            return(Result.SuccessFul());
        }
Esempio n. 15
0
 public async Task <ApiResult <DeleteResult> > Delete([FromRoute] string id)
 {
     if (!ObjectId.TryParse(id, out var objectId))
     {
         throw new HttpBadRequestException
               (
                   new ApiError
                   (
                       nameof(BadRequest),
                       $"Id was not a valid MongoDB id: {{{nameof(id)}}}",
                       additionalData: new Dictionary <string, string> {
             { nameof(id), id }
         }
                   )
               );
     }
     return(await _repository.DeleteAsync <LocalizationModel>(CollectionName, x => x.Id == objectId));
 }
Esempio n. 16
0
        //删除分享


        public async Task <Response <bool> > DelMyKnowledgeShare(string id)
        {
            Response <bool> response = new Response <bool>();

            try {
                _repository.Delete(id);
                _repository.SaveChanges();
                await _mongoRepository.DeleteAsync <Post>(p => p.PostGuid == id);

                response.Data = true;
            }
            catch (Exception ex)
            {
                response.Status = 0;
                response.Msg    = ex.Message.ToString();
            }

            return(response);
        }
Esempio n. 17
0
        public async Task <Result <long> > DeleteAsync(Expression <Func <TEntity, bool> > filter, CancellationToken cancellationToken)
        {
            if (filter == null)
            {
                return(new Result <long>(0, HttpStatusCode.BadRequest, problemTittle: "Filter cannot be null"));
            }

            long affected;

            try
            {
                affected = await _repositoryBase.DeleteAsync(filter, cancellationToken);
            }
            catch (Exception)
            {
                return(new Result <long>(0, HttpStatusCode.InternalServerError, problemTittle: $"Error on delete objects {typeof(TEntity).Name}."));
            }

            return(new Result <long>(affected, HttpStatusCode.OK));
        }
        public async Task <Result> Handle(DeleteDepartmentCommand request, CancellationToken cancellationToken)
        {
            var department = await _departmentRepository.GetAsync(request.Id, cancellationToken);

            if (department is null)
            {
                return(Result.Failed(
                           new NotFoundObjectResult(new ApiMessage(ResponseMessage.DepartmentNotFound))));
            }

            if (_currentUserService.RoleName == Role.Manager && department.Manager.Id != Guid.Parse(_currentUserService.UserId))
            {
                return(Result.Failed(new BadRequestObjectResult(new ApiMessage(ResponseMessage.DeleteNotAllowed))));
            }


            await _departmentRepository.DeleteAsync(request.Id);

            return(Result.SuccessFul());
        }
Esempio n. 19
0
        public async Task <bool> DeleteComplexString(int identifier)
        {
            ComplexString toDelete = await _complexStringRepository.GetAsync(identifier);

            int projectId = toDelete.ProjectId;

            if (toDelete.PictureLink != null)
            {
                await _fileStorageProvider.DeleteFileAsync(toDelete.PictureLink);
            }

            await _unitOfWork.GetRepository <Polyglot.DataAccess.Entities.ComplexString>().DeleteAsync(identifier);

            await _unitOfWork.SaveAsync();

            await _complexStringRepository.DeleteAsync(identifier);

            await this._signalRWorkspaceService.ComplexStringRemoved($"{Group.project}{projectId}", identifier);

            return(true);
        }
        public async Task <Result> Handle(DeleteCategoryCommand request, CancellationToken cancellationToken)
        {
            var category = await _toolCategoryRepository.GetAsync(request.Id, cancellationToken);

            if (category is null)
            {
                return(Result.Failed(new NotFoundObjectResult(new ApiMessage(ResponseMessage.CategoryNotFound))));
            }

            if (await _departmentRepository
                .ExistsAsync(x => x.IsDeleted == false &&
                             x.ToolsCategories.Any(tc => tc.Id == request.Id), cancellationToken))
            {
                return(Result.Failed(new BadRequestObjectResult(
                                         new ApiMessage(ResponseMessage.CategoryInDepartment))));
            }



            await _toolCategoryRepository.DeleteAsync(request.Id);

            return(Result.SuccessFul());
        }
 public Task DeleteAsync(string issueId) => _repository.DeleteAsync(issueId);
 public Task DeleteAsync(AggregateId id)
 => _repository.DeleteAsync(id);
        public async Task Delete(Guid userId)
        {
            var filter = Builders <User> .Filter.Eq(u => u.UserId, userId);

            await _repository.DeleteAsync(filter);
        }
Esempio n. 24
0
 public Task DeleteAsync(EntityId id)
 => _repository.DeleteAsync(id);
Esempio n. 25
0
 public Task DeleteAsync(Expression <Func <User, bool> > predicate)
 => _mongoRepository.DeleteAsync(predicate);
Esempio n. 26
0
 public async Task DeleteAsync(Guid id)
 => await _collection.DeleteAsync(id);
Esempio n. 27
0
 public async Task DeleteAsync(AggregateId id)
 {
     await _repository.DeleteAsync(id);
 }
Esempio n. 28
0
 public Task DeleteAsync(Guid id) => _repository.DeleteAsync(id);
Esempio n. 29
0
        public async Task <ApiResult <DeleteResult> > Delete([FromRoute] string id)
        {
            var objectId = ConvertObjectId(id);

            return(await _repository.DeleteAsync <DynamicForm>(CollectionName, x => x.Id == objectId));
        }
Esempio n. 30
0
 public async Task DeleteAsync(Guid id)
 => await _repository.DeleteAsync(id);