コード例 #1
0
        public async Task CreateStatusAsync(CreateStatusCommand command)
        {
            if (command.Id == Guid.Empty)
            {
                throw new AggregateValidationException("Status Id is invalid.");
            }

            var status = await repository.GetAsync(command.Id);

            if (status != null)
            {
                throw new AggregateIllegalLogicException("Cannot create status with this Id. Status exists.");
            }

            await repository.CreateAsync(new StatusEntity(command.Id, command.Name));
        }
コード例 #2
0
        public async Task <IEnumerable <ApplicationDto> > BrowseApplicationsAsync(GetApplicationsQuery query)
        {
            var applications = await applicationRepository.GetAllAsync();

            var applicationsDtos = mapper.Map <IEnumerable <ApplicationDto> >(applications);

            var results = applicationsDtos.Select(async app =>
            {
                var status = await statusesRepository.GetAsync(app.StatusId);
                if (status != null)
                {
                    app.StatusName = status.Name;
                }
                return(app);
            });

            return(await Task.WhenAll(results));
        }