コード例 #1
0
        public async Task <Unit> Handle(UpdateEntity request, CancellationToken cancellationToken)
        {
            var solution = await _solutionRepository.GetEntities()
                           .Where(e => e.Id == request.SolutionId)
                           .FirstOrDefaultAsync();

            var solutionAccessor = new SolutionAccessor(solution.Path);
            var newEntity        = _mapper.Map <UpdateEntity, Generator.Models.Entity>(request);
            var oldEntity        = (await solutionAccessor.GetEntitiesAsync()).FirstOrDefault(e => e.Id == request.Id);
            await solutionAccessor.UpdateEntityAsync(newEntity);

            // reload Entity from Solution
            newEntity = (await solutionAccessor.GetEntitiesAsync())
                        .FirstOrDefault(e => e.Id == request.Id);
            await _codeGenerator.UpgradeEntityAsync(solutionAccessor, oldEntity, newEntity);

            await _codeGenerator.UpgradeViewAsync(solutionAccessor, new Generator.Models.View(), oldEntity, newEntity);

            return(Unit.Value);
        }