Beispiel #1
0
        public async Task <IOperationResult> Delete(DeleteOperation <BlogPost> model)
        {
            try
            {
                var entityToMarkAsDeleted = _repository.Find <BlogPost>(page => page.Id == model.EntityId);

                entityToMarkAsDeleted.IsRemoved         = true;
                entityToMarkAsDeleted.Content.IsRemoved = true;

                _repository.Update(entityToMarkAsDeleted);

                var removedEntity = new RemovedEntity(entityToMarkAsDeleted.Id, model.UserId);
                _repository.Add(removedEntity);

                await _repository.SaveChangesAsync();

                await _repository.AggregateEntityHistory(entityToMarkAsDeleted.Id, model.UserId, OperationType.Delete);

                return(OperationResult.Success);
            }
            catch (Exception ex)
            {
                return(OperationResult.Failed(ex.Message));
            }
        }
Beispiel #2
0
        public async Task <IOperationResult> Delete(DeleteOperation <Page> model)
        {
            try
            {
                var entityToMarkAsDeleted = _repository.Find <Page>(page => page.Id == model.EntityId);

                entityToMarkAsDeleted.IsRemoved = true;


                if (entityToMarkAsDeleted.PageContentType == PageContentType.Blog)
                {
                    entityToMarkAsDeleted.Blog.IsRemoved = true;
                    foreach (var entity in entityToMarkAsDeleted.Blog?.BlogPosts)
                    {
                        entity.IsRemoved         = true;
                        entity.Content.IsRemoved = true;
                    }
                }
                else
                {
                    entityToMarkAsDeleted.StaticContent.IsRemoved = true;
                }

                _repository.Update(entityToMarkAsDeleted);

                var removedEntity = new RemovedEntity(entityToMarkAsDeleted.Id, model.UserId);
                _repository.Add(removedEntity);

                await _repository.SaveChangesAsync();

                await _repository.AggregateEntityHistory(entityToMarkAsDeleted.Id, model.UserId, OperationType.Delete);

                return(OperationResult.Success);
            }
            catch (Exception ex)
            {
                return(OperationResult.Failed(ex.Message));
            }
        }