public async Task SaveSettingAsync(SaveAccountSettingRequestDTO dto) { var mapper = new SettingMapper(); var registryItemKey = $"{mapper.UserSettingString(dto.UserName)}{dto.Key}"; var registryItemValue = dto.Value.ToString(); var existingRegistryItem = await _context.Registry.SingleOrDefaultAsync(x => x.Key == registryItemKey); if (existingRegistryItem != null) { existingRegistryItem.Value = registryItemValue; } else { var newRegistryItem = new RegistryItem { Id = Guid.NewGuid(), Key = registryItemKey, Value = registryItemValue }; _context.Registry.Add(newRegistryItem); } }
public async Task <IActionResult> Setting([FromBody] SaveAccountSettingRequestDTO dto) { await _unitOfWork.AccountRepository.SaveSettingAsync(dto); await _unitOfWork.SaveAsync(); return(Ok()); }