Пример #1
0
        public async Task ExecuteAsync(SetupCofoundryCommand command, IExecutionContext executionContext)
        {
            var settings = await _domainRepository.ExecuteQueryAsync(new GetSettingsQuery <InternalSettings>());

            if (settings.IsSetup)
            {
                throw new InvalidOperationException("Site is already set up.");
            }

            using (var scope = _domainRepository.Transactions().CreateScope())
            {
                var userId = await CreateAdminUser(command);

                var settingsCommand = await _domainRepository.ExecuteQueryAsync(new GetPatchableCommandQuery <UpdateGeneralSiteSettingsCommand>());

                settingsCommand.ApplicationName = command.ApplicationName;
                await _domainRepository.ExecuteCommandAsync(settingsCommand);

                // Take the opportunity to break the cache in case any additional install scripts have been run since initialization
                _objectCacheFactory.Clear();

                // Setup Complete
                await _domainRepository.ExecuteCommandAsync(new MarkAsSetUpCommand());

                await scope.CompleteAsync();
            }
        }
        public async Task <JsonResult> Get()
        {
            var query   = new GetAllBreedsQuery();
            var results = await _domainRepository.ExecuteQueryAsync(query);

            return(_apiResponseHelper.SimpleQueryResponse(results));
        }
Пример #3
0
        public async Task <JsonResult> Get([FromQuery] SearchCatSummariesQuery query)
        {
            if (query == null)
            {
                query = new SearchCatSummariesQuery();
            }
            var results = await _domainRepository.ExecuteQueryAsync(query);

            return(_apiResponseHelper.SimpleQueryResponse(results));
        }
Пример #4
0
        /// <summary>
        /// Patches a command to modify the current state and then executes it.
        /// </summary>
        /// <typeparam name="TCommand">Type of command to patch and execute.</typeparam>
        /// <param name="id">
        /// The integer database identifier of the entity associated with
        /// patchable command.
        /// </param>
        /// <param name="commandPatcher">
        /// An action to configure or "patch" a command that's been initialized
        /// with existing data.
        /// </param>
        public static async Task PatchCommandAsync <TCommand>(this IDomainRepository repository, int id, Action <TCommand> commandPatcher)
            where TCommand : IPatchableByIdCommand
        {
            var query   = new GetPatchableCommandByIdQuery <TCommand>(id);
            var command = await repository.ExecuteQueryAsync(query);

            commandPatcher(command);

            await repository.ExecuteCommandAsync(command);
        }
        public async Task <JsonResult> PatchDraft(int pageId, [FromBody] IDelta <UpdatePageDraftVersionCommand> delta)
        {
            // Custom patching because we may need to create a draft version first
            var query   = new GetPatchableCommandByIdQuery <UpdatePageDraftVersionCommand>(pageId);
            var command = await _domainRepository.ExecuteQueryAsync(query);

            if (command == null)
            {
                var createDraftCommand = new AddPageDraftVersionCommand();
                createDraftCommand.PageId = pageId;
                await _domainRepository.ExecuteCommandAsync(createDraftCommand);

                command = await _domainRepository.ExecuteQueryAsync(query);
            }

            delta.Patch(command);

            return(await _apiResponseHelper.RunCommandAsync(command));
        }
        public async Task <JsonResult> GetDataModelSchema(string customEntityDefinitionCode)
        {
            var result = await _domainRepository.ExecuteQueryAsync(new GetCustomEntityDataModelSchemaDetailsByDefinitionCodeQuery(customEntityDefinitionCode));

            var settings     = _dynamicDataModelSchemaJsonSerializerSettingsCache.GetInstance();
            var jsonResponse = _apiResponseHelper.SimpleQueryResponse(result);

            jsonResponse.SerializerSettings = settings;

            return(jsonResponse);
        }
        public async Task <JsonResult> GetByName(string dataModelName)
        {
            var result = await _domainRepository.ExecuteQueryAsync(new GetNestedDataModelSchemaByNameQuery(dataModelName));

            var settings     = _dynamicDataModelSchemaJsonSerializerSettingsCache.GetInstance();
            var jsonResponse = _apiResponseHelper.SimpleQueryResponse(result);

            jsonResponse.SerializerSettings = settings;

            return(jsonResponse);
        }
Пример #8
0
        public async Task <JsonResult> GetLikedCats()
        {
            // Here we get the userId of the currently logged in member. We could have
            // done this in the query handler, but instead we've chosen to keep the query
            // flexible so it can be re-used in a more generic fashion
            var userContext = await _userContextService.GetCurrentContextAsync();

            var query   = new GetCatSummariesByMemberLikedQuery(userContext.UserId.Value);
            var results = await _domainRepository.ExecuteQueryAsync(query);

            return(_apiResponseHelper.SimpleQueryResponse(results));
        }
Пример #9
0
        public async Task<JsonResult> GetAuthSession()
        {
            var member = await _domainRepository.ExecuteQueryAsync(new GetCurrentMemberSummaryQuery());
            var token = _antiforgery.GetAndStoreTokens(HttpContext);

            var sessionInfo = new
            {
                Member = member,
                AntiForgeryToken = token.RequestToken
            };

            return _apiResponseHelper.SimpleQueryResponse(sessionInfo);
        }
Пример #10
0
        public async Task <ActionResult> Index()
        {
            var settings = await _domainRepository.ExecuteQueryAsync(new GetSettingsQuery <InternalSettings>());

            if (settings.IsSetup)
            {
                return(RedirectToDashboard());
            }

            // force sign-out - solves a rare case where you're re-initializing a db after being signed into a previous version.
            await _domainRepository.ExecuteCommandAsync(new SignOutCurrentUserFromAllUserAreasCommand());

            var viewPath = ViewPathFormatter.View("Setup", nameof(Index));

            return(View(viewPath));
        }