mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2025-03-13 17:00:25 -09:00
implemented 'delete' functionality
This commit is contained in:
parent
182c0c8f10
commit
b8aaf85604
3 changed files with 18 additions and 2 deletions
|
@ -91,6 +91,11 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories
|
|||
return null;
|
||||
}
|
||||
|
||||
public void DeletePositionById(long positionId)
|
||||
{
|
||||
_db.Delete(POSITION_TABLE_NAME, "id = " + positionId, null);
|
||||
}
|
||||
|
||||
public IList<Position> GetAllPositions(long portfolioId)
|
||||
{
|
||||
var list = new List<Position>();
|
||||
|
|
|
@ -12,5 +12,6 @@ namespace MonoStockPortfolio.Core.PortfolioRepositories
|
|||
Portfolio GetPortfolioById(long portfolioId);
|
||||
void SavePosition(Position position);
|
||||
Portfolio GetPortfolioByName(string portfolioName);
|
||||
void DeletePositionById(long positionId);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ using Android.OS;
|
|||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using MonoStockPortfolio.Core;
|
||||
using MonoStockPortfolio.Core.PortfolioRepositories;
|
||||
using MonoStockPortfolio.Core.Services;
|
||||
using MonoStockPortfolio.Entities;
|
||||
using MonoStockPortfolio.Framework;
|
||||
|
@ -19,6 +20,7 @@ namespace MonoStockPortfolio.Activites
|
|||
public partial class PortfolioActivity : Activity
|
||||
{
|
||||
[IoC] private IPortfolioService _svc;
|
||||
[IoC] private IPortfolioRepository _repo;
|
||||
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
|
@ -67,11 +69,19 @@ namespace MonoStockPortfolio.Activites
|
|||
{
|
||||
if (item.Title.ToS() == "Edit")
|
||||
{
|
||||
Toast.MakeText(this, "edit: " + item.ItemId, ToastLength.Long).Show();
|
||||
// Edit
|
||||
// var intent = new Intent();
|
||||
// intent.SetClassName(this, EditPortfolioActivity.ClassName);
|
||||
// intent.PutExtra(EditPortfolioActivity.Extra_PortfolioID, (long)item.ItemId);
|
||||
// StartActivityForResult(intent, 0);
|
||||
// return true;
|
||||
}
|
||||
else if (item.Title.ToS() == "Delete")
|
||||
{
|
||||
Toast.MakeText(this, "delete: " + item.ItemId, ToastLength.Long).Show();
|
||||
// Delete
|
||||
_repo.DeletePositionById(item.ItemId);
|
||||
Refresh();
|
||||
return true;
|
||||
}
|
||||
return base.OnContextItemSelected(item);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue