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); }
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); }
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 })); }
/// <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); }
private void RaisePortfolioChanged(Portfolio portfolio) { PortfolioChanged?.Invoke(portfolio); PortfoliosChanged?.Invoke(new[] { portfolio }); }