From 1181a0920a4edbd17c637b61c6922f99e184f224 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Tue, 28 Oct 2025 17:55:41 +0700 Subject: [PATCH] Remove doc required --- .../Controllers/TradingController.cs | 61 +++++++++---------- .../Models/Requests/IndicatorRequestDto.cs | 12 ++-- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/Managing.Api/Controllers/TradingController.cs b/src/Managing.Api/Controllers/TradingController.cs index db2e7a6d..b3ff824b 100644 --- a/src/Managing.Api/Controllers/TradingController.cs +++ b/src/Managing.Api/Controllers/TradingController.cs @@ -105,7 +105,7 @@ public class TradingController : BaseController public async Task> ClosePosition(Guid identifier) { var position = await _tradingService.GetPositionByIdentifierAsync(identifier); - + var result = await _closeTradeCommandHandler.Handle(new ClosePositionCommand(position, position.AccountId)); return Ok(result); } @@ -190,7 +190,8 @@ public class TradingController : BaseController // Check if user has permission to initialize this address if (!await CanUserInitializeAddress(user.Name, publicAddress)) { - return Forbid("You don't have permission to initialize this wallet address. You can only initialize your own wallet addresses."); + return Forbid( + "You don't have permission to initialize this wallet address. You can only initialize your own wallet addresses."); } var result = await _tradingService.InitPrivyWallet(publicAddress, TradingExchanges.GmxV2); @@ -228,19 +229,22 @@ public class TradingController : BaseController // Regular users can only initialize their own addresses // Check if the address belongs to one of the user's accounts var account = await _accountService.GetAccountByKey(publicAddress, true, false); - + if (account?.User?.Name == userName) { - _logger.LogInformation("User {UserName} initializing their own address {Address}", userName, publicAddress); + _logger.LogInformation("User {UserName} initializing their own address {Address}", userName, + publicAddress); return true; } - - _logger.LogWarning("User {UserName} attempted to initialize address {Address} that doesn't belong to them", userName, publicAddress); + + _logger.LogWarning("User {UserName} attempted to initialize address {Address} that doesn't belong to them", + userName, publicAddress); return false; } catch (Exception ex) { - _logger.LogWarning(ex, "Unable to verify ownership of address {Address} for user {UserName}", publicAddress, userName); + _logger.LogWarning(ex, "Unable to verify ownership of address {Address} for user {UserName}", publicAddress, + userName); return false; } } @@ -268,11 +272,6 @@ public class TradingController : BaseController return BadRequest("Strategy is required."); } - if (string.IsNullOrWhiteSpace(request.DocumentationUrl)) - { - return BadRequest("Documentation URL is required."); - } - if (string.IsNullOrWhiteSpace(request.RequesterName)) { return BadRequest("Requester name is required."); @@ -281,7 +280,7 @@ public class TradingController : BaseController try { var webhookUrl = _configuration["N8n:IndicatorRequestWebhookUrl"]; - + if (string.IsNullOrEmpty(webhookUrl)) { _logger.LogError("N8n indicator request webhook URL is not configured"); @@ -289,26 +288,26 @@ public class TradingController : BaseController } var httpClient = _httpClientFactory.CreateClient(); - + _logger.LogInformation( "Submitting indicator request: {IndicatorName} - {Strategy} by {Requester}", - request.IndicatorName, - request.StrategyDescription, + request.IndicatorName, + request.StrategyDescription, request.RequesterName); // Send as JSON payload var response = await httpClient.PostAsJsonAsync(webhookUrl, request); - + if (response.IsSuccessStatusCode) { _logger.LogInformation( "Successfully submitted indicator request: {IndicatorName} by {Requester}", - request.IndicatorName, + request.IndicatorName, request.RequesterName); - - return Ok(new - { - Success = true, + + return Ok(new + { + Success = true, Message = "Indicator request submitted successfully.", IndicatorName = request.IndicatorName, Strategy = request.StrategyDescription, @@ -322,21 +321,21 @@ public class TradingController : BaseController "Failed to submit indicator request. Status: {StatusCode}, Response: {Response}", response.StatusCode, responseContent); - - return StatusCode(500, new - { - Success = false, - Error = $"Failed to submit indicator request. Status: {response.StatusCode}" + + return StatusCode(500, new + { + Success = false, + Error = $"Failed to submit indicator request. Status: {response.StatusCode}" }); } } catch (Exception ex) { _logger.LogError(ex, "Error submitting indicator request: {IndicatorName}", request.IndicatorName); - return StatusCode(500, new - { - Success = false, - Error = "An error occurred while submitting the indicator request." + return StatusCode(500, new + { + Success = false, + Error = "An error occurred while submitting the indicator request." }); } } diff --git a/src/Managing.Api/Models/Requests/IndicatorRequestDto.cs b/src/Managing.Api/Models/Requests/IndicatorRequestDto.cs index 39641206..64f293d2 100644 --- a/src/Managing.Api/Models/Requests/IndicatorRequestDto.cs +++ b/src/Managing.Api/Models/Requests/IndicatorRequestDto.cs @@ -1,5 +1,7 @@ #nullable enable +using System.ComponentModel.DataAnnotations; + namespace Managing.Api.Models.Requests; /// @@ -10,17 +12,19 @@ public class IndicatorRequestDto /// /// Name of the indicator (e.g., "MACD", "RSI", "Bollinger Bands") /// - public string IndicatorName { get; set; } = string.Empty; + [Required] + public string IndicatorName { get; set; } /// /// Strategy or description of how the indicator is used (e.g., "MACD Cross", "RSI Divergence") /// + [Required] public string StrategyDescription { get; set; } = string.Empty; /// /// Primary documentation URL for the indicator /// - public string DocumentationUrl { get; set; } = string.Empty; + public string? DocumentationUrl { get; set; } /// /// Image URL for the indicator (optional) - can be a chart, diagram, or visual representation @@ -30,6 +34,6 @@ public class IndicatorRequestDto /// /// Name of the person requesting the indicator /// + [Required] public string RequesterName { get; set; } = string.Empty; -} - +} \ No newline at end of file