public async Task <IActionResult> PostFileData([FromBody] ModuleData value) { _logger.LogInformation("File Posted1 Before Save " + value.ModuleName); try { dynamic existing = await _rulesRepository.QueryAsync <RulesModuleModel, RulesModule, object, object> ( q => q.Select(r => new { r.RulesModuleId, r.Application, r.Name }) .SingleOrDefault(r => r.Application == value.Application && r.Name == value.ModuleName) ); RulesModuleModel model = new RulesModuleModel { Application = value.Application, Name = value.ModuleName, RuleSetFile = value.RulesStream, ResourceSetFile = value.ResourcesStream, LastUpdated = DateTime.UtcNow, RulesModuleId = existing == null ? 0 : existing.RulesModuleId, EntityState = existing == null ? LogicBuilder.Domain.EntityStateType.Added : LogicBuilder.Domain.EntityStateType.Modified }; if (await this._rulesRepository.SaveAsync <RulesModuleModel, RulesModule>(model)) { _logger.LogInformation("Saved " + value.ModuleName); await this._rulesManager.LoadSelectedModules(new List <string> { model.Name }); return(Created($"/api/[controller]/{model.RulesModuleId}", model)); } else { _logger.LogInformation("Not Saved " + value.ModuleName); return(BadRequest("Not Saved")); } } catch (Exception ex) { this._logger.LogError(ex, ex.Message); _logger.LogInformation("Exception on Save " + value.ModuleName); return(BadRequest(ex.Message)); } }