public Task <ActionResult <SaveGlobalSettingsResponse> > Save([FromBody] GlobalSettingsForSave settingsForSave, [FromQuery] SaveArguments args) { // Authorized access (Criteria are not supported here) // TODO Authorize //var updatePermissions = await ControllerUtilities.GetPermissions(_db.AbstractPermissions, PermissionLevel.Update, "settings"); //if (!updatePermissions.Any()) //{ // return StatusCode(403); //} //try //{ // // Trim all string fields just in case // settingsForSave.TrimStringProperties(); // // Validate // ValidateAndPreprocessSettings(settingsForSave); // if (!ModelState.IsValid) // { // return UnprocessableEntity(ModelState); // } // // Persist // M.GlobalSettings mSettings = await _repo.GlobalSettings.FirstOrDefaultAsync(); // if (mSettings == null) // { // // This should never happen // return BadRequest("Global settings have not been initialized"); // } // _mapper.Map(settingsForSave, mSettings); // mSettings.SettingsVersion = Guid.NewGuid(); // prompts clients to refresh // await _repo.SaveChangesAsync(); // // IF requested, return the updated entity // if (args.ReturnEntities ?? false) // { // // IF requested, return the same response you would get from a GET // var res = await GetImpl(new GetByIdArguments { Expand = args.Expand }); // var result = new SaveGlobalSettingsResponse // { // CollectionName = res.CollectionName, // Result = res.Result, // RelatedEntities = res.RelatedEntities, // SettingsForClient = GetForClientImpl() // }; // return result; // } // else // { // return Ok(); // } //} //catch (Exception ex) //{ // _logger.LogError($"Error: {ex.Message} {ex.StackTrace}"); // return BadRequest(ex.Message); //} throw new NotImplementedException(); }
private void ValidateAndPreprocessSettings(GlobalSettingsForSave entity) { }