Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,5 @@ Generated_Code #added for RIA/Silverlight projects
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.XML
*.userprefs
2 changes: 0 additions & 2 deletions Framework.iOS/Framework.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0166E991-1FED-4430-AF57-BC51E774B9A3}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
Expand Down
3 changes: 0 additions & 3 deletions QBank.Api/QBank.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2E622B76-DE24-4398-BB9A-D6EB06723334}</ProjectGuid>
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349C5851-65DF-11DA-9384-00065B846F21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
Expand Down
2 changes: 0 additions & 2 deletions QBank.DataAccess/QBank.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1DA1F168-7E36-468A-AF9C-6167233200F5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
Expand Down
2 changes: 0 additions & 2 deletions QBank.Infrastructure.Web/QBank.Infrastructure.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
Expand Down
2 changes: 0 additions & 2 deletions QBank.Model/QBank.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C8386F02-74E2-48D6-8D87-3F151203AC46}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
Expand Down
2 changes: 0 additions & 2 deletions QBank.Service/QBank.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
Expand Down
5 changes: 0 additions & 5 deletions QBank.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Global
{1DA1F168-7E36-468A-AF9C-6167233200F5}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{1DA1F168-7E36-468A-AF9C-6167233200F5}.AppStore|iPhone.Build.0 = Debug|Any CPU
{1DA1F168-7E36-468A-AF9C-6167233200F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DA1F168-7E36-468A-AF9C-6167233200F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DA1F168-7E36-468A-AF9C-6167233200F5}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{1DA1F168-7E36-468A-AF9C-6167233200F5}.Debug|iPhone.Build.0 = Debug|Any CPU
{1DA1F168-7E36-468A-AF9C-6167233200F5}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand All @@ -75,7 +74,6 @@ Global
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.AppStore|iPhone.Build.0 = Debug|Any CPU
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.Debug|iPhone.Build.0 = Debug|Any CPU
{24FBFD89-0069-408A-A6BF-ECF0CA5E019E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand All @@ -91,7 +89,6 @@ Global
{2E622B76-DE24-4398-BB9A-D6EB06723334}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{2E622B76-DE24-4398-BB9A-D6EB06723334}.AppStore|iPhone.Build.0 = Debug|Any CPU
{2E622B76-DE24-4398-BB9A-D6EB06723334}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E622B76-DE24-4398-BB9A-D6EB06723334}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E622B76-DE24-4398-BB9A-D6EB06723334}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{2E622B76-DE24-4398-BB9A-D6EB06723334}.Debug|iPhone.Build.0 = Debug|Any CPU
{2E622B76-DE24-4398-BB9A-D6EB06723334}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -127,7 +124,6 @@ Global
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.AppStore|iPhone.Build.0 = Debug|Any CPU
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.Debug|iPhone.Build.0 = Debug|Any CPU
{90CAC7EC-480B-43D6-824F-6C59DA02F6F9}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand All @@ -143,7 +139,6 @@ Global
{C8386F02-74E2-48D6-8D87-3F151203AC46}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{C8386F02-74E2-48D6-8D87-3F151203AC46}.AppStore|iPhone.Build.0 = Debug|Any CPU
{C8386F02-74E2-48D6-8D87-3F151203AC46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8386F02-74E2-48D6-8D87-3F151203AC46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8386F02-74E2-48D6-8D87-3F151203AC46}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{C8386F02-74E2-48D6-8D87-3F151203AC46}.Debug|iPhone.Build.0 = Debug|Any CPU
{C8386F02-74E2-48D6-8D87-3F151203AC46}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand Down
27 changes: 27 additions & 0 deletions iOS.Client/DataAccess/AccountsRepository.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using iOS.Client.Model;
using System.Collections.Generic;
using System.Linq;

namespace iOS.Client
{
public interface IAccountsRepository
{
Account GetByAccountNumber(string accountNumber);
IEnumerable<Account> GetAccountByCustomerId(int id);
Account ProcessDeposit (Account account, Transaction transaction);
Account ProcessCredit (Account account, Transaction transaction);
}

public class AccountsRepository: IAccountsRepository
Expand All @@ -26,6 +29,30 @@ public IEnumerable<Account> GetAccountByCustomerId (int id)
return seedAccounts;
}

public Account ProcessDeposit(Account account, Transaction transaction)
{
return ProcessTransaction (account, transaction, true);
}

public Account ProcessCredit(Account account, Transaction transaction)
{
return ProcessTransaction (account, transaction, false);
}

private Account ProcessTransaction(Account account, Transaction transaction, bool isDeposit)
{
var now = DateTime.Now;

account.Transactions.Add(transaction);

if (isDeposit)
account.Balance += transaction.Amount;
else
account.Balance -= transaction.Amount;

return account;
}

#endregion

public AccountsRepository ()
Expand Down
46 changes: 46 additions & 0 deletions iOS.Client/Element/AccountRootElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public float GetHeight (UITableView tableView, NSIndexPath indexPath)
NSString _cellKey = new NSString("AccountCell");
Account _account;
bool _showIndicator;
bool _createAddButton;
private UIBarButtonItem _addButton;
IAccountsRepository _repository;

public UINavigationController NavigationController { get; set; }

protected override NSString CellKey {get {return _cellKey;}}

Expand All @@ -36,9 +41,50 @@ public AccountRootElement (Account account, bool showIndicator, Func<RootElement
_account = account;
}

public AccountRootElement (IAccountsRepository accountRepo, Account account, bool showIndicator, Func<RootElement,UIViewController> createOnSelected, bool createAddButton) : base(account.AccountNumber,createOnSelected )
{
this._showIndicator = showIndicator;
_account = account;
_createAddButton = createAddButton;
_repository = accountRepo;
}

public AccountRootElement (Account account):base(account.AccountNumber)
{
_account = account;
}

protected override void PrepareDialogViewController (UIViewController dvc)
{
base.PrepareDialogViewController (dvc);

if (!_createAddButton)
return;

accountRoot = (dvc as DialogViewController).Root;

_addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add, AddTransaction);
dvc.NavigationItem.RightBarButtonItem = _addButton;
}

RootElement accountRoot;

private void AddTransaction(object sender, EventArgs e)
{
var transactionView = new Transactions (_repository, _account);
transactionView.SaveCompleted += (transaction) =>
{
// gets the section that contains the transactions and adds
// new transaction element to the section
var section = accountRoot[1];
section.Add(new TransactionElement(transaction));

// updates the account section to updated the account balance.
var accountSection = new Section() { new AccountElement(_account, false) };
accountRoot.RemoveAt(0);
accountRoot.Insert(0, accountSection);
};

NavigationController.PushViewController (transactionView, true);
}
}
9 changes: 8 additions & 1 deletion iOS.Client/Screens/Accounts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RootElement CreateNewRoot(IEnumerable<IGrouping<string, Account>> accountsByGrou
in accountsByGroup
select new Section () { // i.e.: Deposits
from account in _group select
new AccountRootElement(account,true, StyleTransactionsScreen)
new AccountRootElement(accountRepo: repository, account: account, showIndicator: true, createOnSelected: StyleTransactionsScreen, createAddButton: true)
{
new Section() // Section for Account Header
{
Expand Down Expand Up @@ -86,5 +86,12 @@ void CreateScreen ()
accountsByGroup = model.GroupBy (g => g.AccountType);

Root = CreateNewRoot(accountsByGroup);

for (int i = 0; i < Root.Count; i++)
{
var section = Root [i];
var accountRootElement = (AccountRootElement)section.Elements [0];
accountRootElement.NavigationController = this.NavigationController;
}
}
}
112 changes: 112 additions & 0 deletions iOS.Client/Screens/Transaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using iOS.Client.Model;

namespace iOS.Client
{
public partial class Transactions : DialogViewController
{
IAccountsRepository _repository;
Account _account;

private bool IsDeposit
{
get { return _account.AccountType == "Deposit" || _account.AccountType == "Savings"; }
}

public Action<Transaction> SaveCompleted;

public Transactions (IAccountsRepository repository, Account account) : base (UITableViewStyle.Grouped, null)
{
_repository = repository;
_account = account;
}

public override void LoadView ()
{
base.LoadView ();
CreateScreen ();
ApplyStyle ();
}

public void ApplyStyle()
{
Root.TableView.SeparatorColor = UIColor.FromPatternImage (Resources.CellSeparator);
Root.TableView.BackgroundView = new UIImageView (UIImage.FromBundle ("paper.png"));
}

private void CreateNewRoot()
{
Root = new RootElement ("Add Transaction");

var section = new Section (string.Empty)
{
new DateElement ("Transaction Date", DateTime.Now),
new EntryElement ("Description", "", ""),
new EntryElement ("Amount", "", "") { KeyboardType = UIKeyboardType.DecimalPad },
};

Root.Add (section);

var saveSection = new Section (string.Empty);
var saveButton = new StyledStringElement ("Save", () =>
{
float amount = 0f;

if (!float.TryParse((section.Elements[2] as EntryElement).Value, out amount))
{
new UIAlertView("Amount Error", "Amount must be a numeric value and is required", null, "Ok", null).Show();
return;
}

var transaction = new Transaction ()
{
OccuredOn = (section.Elements[0] as DateElement).DateValue,
Amount = amount,
Description = (section.Elements[1] as EntryElement).Value,
RemainingBalance = CalculateBalance(amount)
};

if (IsDeposit)
_repository.ProcessDeposit(_account, transaction);
else
_repository.ProcessCredit(_account, transaction);

if (SaveCompleted != null)
SaveCompleted(transaction);

NavigationController.PopViewControllerAnimated(true);

});
saveSection.Add (saveButton);
Root.Add (saveSection);
}

private double CalculateBalance(float amount)
{
if (IsDeposit)
return _account.Balance + amount;
else
{
if (_account.Balance > 0)
return _account.Balance - amount;
else
return _account.Balance + amount;
}
}

private void CreateScreen ()
{
NavigationItem.TitleView = new UIImageView (UIImage.FromBundle ("logo"));
NavigationItem.LeftBarButtonItem = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Done, (s, e) =>
{
NavigationController.PopViewControllerAnimated(true);
});
CreateNewRoot();
}
}
}
13 changes: 7 additions & 6 deletions iOS.Client/iOS.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{842ADB2E-6B84-48C8-820B-AA72955D78F2}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
Expand Down Expand Up @@ -40,7 +38,8 @@
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<AssemblyName>iOS</AssemblyName>
<MtouchI18n />
<MtouchI18n>
</MtouchI18n>
<MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
Expand All @@ -65,8 +64,10 @@
<MtouchDebug>true</MtouchDebug>
<CodesignKey>iPhone Developer</CodesignKey>
<AssemblyName>QBank</AssemblyName>
<IpaPackageName />
<MtouchI18n />
<IpaPackageName>
</IpaPackageName>
<MtouchI18n>
</MtouchI18n>
<MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
Expand Down Expand Up @@ -122,6 +123,7 @@
<Compile Include="Element\TransactionCell.cs" />
<Compile Include="Element\TransactionElement.cs" />
<Compile Include="Element\AccountRootElement.cs" />
<Compile Include="Screens\Transaction.cs" />
</ItemGroup>
<ItemGroup>
<XamarinComponent Include="btprogresshud">
Expand Down Expand Up @@ -185,7 +187,6 @@
</ItemGroup>
<ItemGroup>
<XamarinComponentReference Include="btprogresshud">
<InstallationInProgress>True</InstallationInProgress>
<Version>1.5</Version>
<Visible>False</Visible>
</XamarinComponentReference>
Expand Down