コード例 #1
0
        public async Task <PortfolioImage> AddImageToPortfolio(string imageSource)
        {
            var response = await HttpClient.PostAsync(GetPortfolioUri,
                                                      new MultipartFormDataContent
            {
                {
                    new ByteArrayContent(File.ReadAllBytes(imageSource)), "\"photo\"",
                    $"\"{imageSource.Substring(imageSource.LastIndexOf('/') + 1)}\""
                }
            });

            var json = await response.Content.ReadAsStringAsync();

            Debug.WriteLine(json);

            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }

            var data = JsonConvert.DeserializeObject <ResponseDto <PortfolioImage> >(json);

            if (!data.Success)
            {
                return(null);
            }
            PortfolioChanged?.Invoke(this, EventArgs.Empty);
            data.Data.ImageSource = Domain + data.Data.ImageSource;
            return(data.Data);
        }
コード例 #2
0
        public async Task <bool> RemoveImageFromPortfolio(Guid uuid)
        {
            var response = await HttpClient.DeleteAsync(string.Format(PortfolioUri, uuid));

            if (response.IsSuccessStatusCode)
            {
                PortfolioChanged?.Invoke(this, EventArgs.Empty);
            }
            return(response.IsSuccessStatusCode);
        }
コード例 #3
0
 internal void OnPortfolioAction(PortfolioActionResponse message)
 {
     PortfolioChanged?.Invoke(this, new EventArgs<PortfolioActionEventArgs>(new PortfolioActionEventArgs
     {
         PortfolioName = message.Portfolio.Name,
         Portfolio = message.Portfolio,
         Error = message.Error,
         IsRemoving = message.Action == PortfolioAction.Remove
     }));
 }
コード例 #4
0
        /// <summary>
        /// Remove security.
        /// </summary>
        /// <param name="portfolio">Portfolio.</param>
        /// <returns>Check result.</returns>
        public bool Remove(Portfolio portfolio)
        {
            if (portfolio is null)
            {
                throw new ArgumentNullException(nameof(portfolio));
            }

            if (!_inner.Remove(portfolio.Name))
            {
                return(false);
            }

            PortfolioChanged?.Invoke(portfolio);
            return(true);
        }
コード例 #5
0
ファイル: Connector_Raise.cs プロジェクト: vskynet/StockSharp
 private void RaisePortfolioChanged(Portfolio portfolio)
 {
     PortfolioChanged?.Invoke(portfolio);
     PortfoliosChanged?.Invoke(new[] { portfolio });
 }