Esempio n. 1
0
        public async Task <TEntity> CreateAsync(TEntity entity)
        {
            var result = (await DbSet.AddAsync(entity)).Entity;
            await ElasticRepository.UpdateSearchIndex(result, CrudAction.Create);

            return(result);
        }
Esempio n. 2
0
        public async Task <TEntity> Update(TEntity entity)
        {
            var result = DbSet.Update(entity).Entity;

            await ElasticRepository.UpdateSearchIndex(result, CrudAction.Update);

            return(result);
        }
Esempio n. 3
0
        public async Task <bool> UpdateBool(TEntity entity)
        {
            var entityDb = entity as Entity;

            if (entityDb != null)
            {
                var existingEntity = DbSet.Find(entityDb.Id);
                if (existingEntity == null)
                {
                    return(false);
                }

                context.Entry(existingEntity).State = EntityState.Detached;
                await ElasticRepository.UpdateSearchIndex(existingEntity, CrudAction.Update);
            }

            context.Entry(entity).State = EntityState.Modified;
            return(true);
        }