diff --git a/MonoStockPortfolio.Core/EnumExtensions.cs b/MonoStockPortfolio.Core/EnumExtensions.cs index fa8a8a5..dd1e98d 100644 --- a/MonoStockPortfolio.Core/EnumExtensions.cs +++ b/MonoStockPortfolio.Core/EnumExtensions.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; using MonoStockPortfolio.Entities; namespace MonoStockPortfolio.Core @@ -24,16 +21,5 @@ namespace MonoStockPortfolio.Core } return string.Empty; } - - public static IEnumerable GetValues(this Enum value) - { - var enumerations = new List(); - var fields = value.GetType().GetFields(BindingFlags.Static | BindingFlags.Public); - foreach (var fieldInfo in fields) - { - enumerations.Add((Enum)fieldInfo.GetValue(value)); - } - return enumerations.Cast(); - } } } \ No newline at end of file diff --git a/MonoStockPortfolio.Core/PortfolioRepositories/IPortfolioRepository.cs b/MonoStockPortfolio.Core/PortfolioRepositories/IPortfolioRepository.cs index b1da401..74e7e47 100644 --- a/MonoStockPortfolio.Core/PortfolioRepositories/IPortfolioRepository.cs +++ b/MonoStockPortfolio.Core/PortfolioRepositories/IPortfolioRepository.cs @@ -8,10 +8,11 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories IList GetAllPortfolios(); void SavePortfolio(Portfolio portfolio); void DeletePortfolioById(int portfolioId); - IList GetAllPositions(long portfolioId); Portfolio GetPortfolioById(long portfolioId); - void SavePosition(Position position); Portfolio GetPortfolioByName(string portfolioName); + + IList GetAllPositions(long portfolioId); + void SavePosition(Position position); void DeletePositionById(long positionId); Position GetPositionById(long positionId); } diff --git a/MonoStockPortfolio.Core/Services/IPortfolioService.cs b/MonoStockPortfolio.Core/Services/IPortfolioService.cs index 7e21073..6e7a78b 100644 --- a/MonoStockPortfolio.Core/Services/IPortfolioService.cs +++ b/MonoStockPortfolio.Core/Services/IPortfolioService.cs @@ -5,8 +5,6 @@ namespace MonoStockPortfolio.Core.Services { public interface IPortfolioService { - IList GetAllPortfolios(); IEnumerable GetDetailedItems(long portfolioID, IEnumerable items); - Portfolio GetPortolioById(long portfolioId); } } \ No newline at end of file diff --git a/MonoStockPortfolio.Core/Services/PortfolioService.cs b/MonoStockPortfolio.Core/Services/PortfolioService.cs index 66df6f0..2edd6ec 100644 --- a/MonoStockPortfolio.Core/Services/PortfolioService.cs +++ b/MonoStockPortfolio.Core/Services/PortfolioService.cs @@ -13,11 +13,6 @@ namespace MonoStockPortfolio.Core.Services private readonly IPortfolioRepository _portRepo; private readonly IStockDataProvider _stockRepo; -// public PortfolioService(Context context) : this(new AndroidSqlitePortfolioRepository(context), -// new YahooStockDataProvider()) -// { -// } - public PortfolioService(IPortfolioRepository portfolioRepository, IStockDataProvider stockDataProvider) { _portRepo = portfolioRepository; @@ -60,11 +55,6 @@ namespace MonoStockPortfolio.Core.Services } } - public Portfolio GetPortolioById(long portfolioId) - { - return _portRepo.GetPortfolioById(portfolioId); - } - private IDictionary GetStockItems(IEnumerable items, StockQuote quote) { var dict = new Dictionary(); diff --git a/MonoStockPortfolio.Core/StockData/YahooFinanceStockData.cs b/MonoStockPortfolio.Core/StockData/YahooFinanceStockData.cs index f435a06..16462d4 100644 --- a/MonoStockPortfolio.Core/StockData/YahooFinanceStockData.cs +++ b/MonoStockPortfolio.Core/StockData/YahooFinanceStockData.cs @@ -1,4 +1,3 @@ -using System; using FileHelpers; namespace MonoStockPortfolio.Core.StockData diff --git a/MonoStockPortfolio/Activites/EditPortfolioActivity.cs b/MonoStockPortfolio/Activites/EditPortfolioActivity.cs index 85dc49d..6afcf8a 100644 --- a/MonoStockPortfolio/Activites/EditPortfolioActivity.cs +++ b/MonoStockPortfolio/Activites/EditPortfolioActivity.cs @@ -1,8 +1,6 @@ using System; using Android.App; -using Android.Content; using Android.OS; -using Android.Widget; using MonoStockPortfolio.Core.PortfolioRepositories; using MonoStockPortfolio.Entities; using MonoStockPortfolio.Framework; @@ -22,7 +20,7 @@ namespace MonoStockPortfolio.Activites WireUpEvents(); - var portfolioId = Intent.GetLongExtra(Extra_PortfolioID, -1); + var portfolioId = ThisPortfolioId; if(portfolioId != -1) { this.Title = "Edit Portfolio"; @@ -49,11 +47,9 @@ namespace MonoStockPortfolio.Activites { _repo.SavePortfolio(portfolioToSave); - Toast.MakeText(this, "You saved: " + PortfolioName.Text, ToastLength.Short).Show(); + this.LongToast("You saved: " + PortfolioName.Text); - var intent = new Intent(); - SetResult(Result.Ok, intent); - Finish(); + this.EndActivity(); } } @@ -66,7 +62,7 @@ namespace MonoStockPortfolio.Activites var result = validator.Apply(); if(result != string.Empty) { - Toast.MakeText(this, result, ToastLength.Long).Show(); + this.LongToast(result); return false; } return true; @@ -85,7 +81,7 @@ namespace MonoStockPortfolio.Activites private Portfolio GetPortfolioToSave() { Portfolio portfolioToSave; - var portfolioId = Intent.GetLongExtra(Extra_PortfolioID, -1); + var portfolioId = ThisPortfolioId; if (portfolioId != -1) { portfolioToSave = new Portfolio(portfolioId); diff --git a/MonoStockPortfolio/Activites/EditPortfolioActivity.designer.cs b/MonoStockPortfolio/Activites/EditPortfolioActivity.designer.cs index aba69b6..460f96a 100644 --- a/MonoStockPortfolio/Activites/EditPortfolioActivity.designer.cs +++ b/MonoStockPortfolio/Activites/EditPortfolioActivity.designer.cs @@ -6,6 +6,7 @@ namespace MonoStockPortfolio.Activites { public static string ClassName { get { return "monostockportfolio.activites.EditPortfolioActivity"; } } public static string Extra_PortfolioID { get { return "monoStockPortfolio.EditPortfolioActivity.PortfolioID"; } } + public long ThisPortfolioId { get { return Intent.GetLongExtra(Extra_PortfolioID, -1); } } protected Button SaveButton { get { return FindViewById