public async Task<ActionResult> Get(Guid databaseEnvironmentId) { var model = await _userParamService .GetByEnvironmentIdAsync(databaseEnvironmentId); if (model != null) return Ok(model); return NotFound(); }
public async Task <DatabaseEnvironmentBO> DuplicateAsync(Guid databaseEnvironmentId) { var model = await this.GetAsync(databaseEnvironmentId); var databaseEnvironment = new DatabaseEnvironment() { User = model.User, Password = model.Password, Database = model.Database, DataSource = model.DataSource, ExtraData = model.ExtraData, Name = string.Format("{0}_Dup", model.Name), Version = model.Version, MapTables = model.MapTables, MaxNumberResults = model.MaxNumberResults, SecurityIntegrated = model.SecurityIntegrated, TimeoutInMinutes = model.TimeoutInMinutes }; var result = await this._databaseEnvironmentCommands.AddAsync(databaseEnvironment); if (result != null) { var listParams = await _userParamsService.GetByEnvironmentIdAsync(databaseEnvironmentId); if (listParams != null) { listParams.ForEach(rec => { rec.Id = Guid.Empty; rec.DatabaseEnvironmentId = result.Id; }); var newListParams = await _userParamsService.UpdateListAsync(listParams, result.Id); } } return(MapEntityToModel(result)); }