public Task <bool> Handle(RegisterNewConfigurationCommand message, CancellationToken cancellationToken) { //se nao for válido //if (!message.IsValid()) //{ // NotifyValidationErrors(message); // return Task.FromResult(false); //} var configuration = new Configuration(Guid.NewGuid(), message.Calcular_Dezenas_Sem_Pontuacao, message.Enviar_Email_Manualmente, message.Enviar_Email_Automaticamente, message.Checar_Jogo_Online, message.Valor_Minimo_Para_Envio_Email); if (_configurationRepository.GetConfigurationById(configuration.Id) != null) { Bus.RaiseEvent(new DomainNotification(message.MessageType, "O id desta configuração já existe!")); return(Task.FromResult(false)); } _configurationRepository.Add(configuration); if (Commit()) { Bus.RaiseEvent(new ConfigurationRegisteredEvent(configuration.Id, configuration.Calcular_Dezenas_Sem_Pontuacao, configuration.Enviar_Email_Manualmente, configuration.Enviar_Email_Automaticamente, configuration.Checar_Jogo_Online, configuration.Valor_Minimo_Para_Envio_Email)); } return(Task.FromResult(true)); }
private void SaveConfigData() { ConfigurationData.PlaySounds = PlaySounds; ConfigurationData.ShowCheckoutHints = ShowCheckoutHints; _configurationRepository.Add(ConfigurationData); _configurationRepository.Save(); MessageBus.Current.SendMessage(ConfigurationData); }
public async Task Create(ConfigurationDto configurationDto) { if (configurationDto == null) { return; } var configuration = _mapper.Map <Domain.ValueObjects.Configuration>(configurationDto); await _configurationRepository.Add(configuration); }
public HttpResponseMessage Post([FromBody] Configuration configuration) { OnAuthorization(); var value = repository.Add(configuration); if (value == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } // Return 201 status code with the new Configuration's location in the Location header var response = Request.CreateResponse(HttpStatusCode.Created); response.Headers.Location = new Uri(Request.RequestUri, string.Format("configurations/{0}", value.name)); return(response); }
public async Task Create(ApiResourceCreateDto dto) { EnsureModelValid(dto); ApiResource existResource = await FindByName(dto.Name); if (existResource != null) { throw new BadRequestException($"ApiResource with name '{dto.Name}' already exist."); } ApiResource resource = BuildApiResource(dto); _apiResourceRepository.Add(resource); await _apiResourceRepository.SaveChangesAsync(); }
public async Task <IActionResult> Create([FromBody] SaveConfigurationResource configurationResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var configuration = mapper.Map <SaveConfigurationResource, AppConfiguration>(configurationResource); configurationRepository.Add(configuration); if (await unitOfWork.CompleteAsync() == false) { throw new Exception(message: "Create new configuration fail on save"); } configuration = await configurationRepository.GetOne(configuration.Id); var result = mapper.Map <AppConfiguration, ViewConfigurationResource>(configuration); return(Ok(result)); }
private async Task <ClientCreatedDto> Create(Client client) { if (!string.IsNullOrEmpty(client.ClientUri)) { Client existClient = await FindByUri(client.ClientUri); if (existClient != null) { throw new BadRequestException($"A client with uri '{client.ClientUri}' already exists."); } } string clientId = Guid.NewGuid().ToString(); client.ClientId = clientId; string secret = _secretGenerator.Create(); client.ClientSecrets = new List <ClientSecret> { new ClientSecret { Value = _secretGenerator.Hash(secret), Expiration = DateTime.Now.AddYears(Constants.ClientSecretLifeTimeInYear) } }; _clientRepository.Add(client); await _clientRepository.SaveChangesAsync(); return(new ClientCreatedDto { ClientId = clientId, Secret = secret }); }
private async void SaveConfigData() { _configurationRepository.Add(_configurationData); await _configurationRepository.Save(); }
public void Deactivate(object parameter) { _configurationData.EnableSoundRecognition = IsSoundSupportEnabled; _configurationRepository.Add(_configurationData); _configurationRepository.Save(); }