Skip to content
Permalink
Browse files
Expense tracker App completed
  • Loading branch information
doryumusharon committed Nov 19, 2020
1 parent bfcf901 commit 25c60a768ac491ba326a9afa71a8247780dd7310
Show file tree
Hide file tree
Showing 25 changed files with 199 additions and 248 deletions.
@@ -103,7 +103,9 @@
<AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<AndroidResource Include="Resources\drawable\logo.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ExpenseTracker\ExpenseTracker.csproj">
<Project>{801B6533-97C6-486C-9BF4-050D9B494C9B}</Project>
@@ -161,5 +163,11 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable\wind.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\profile.jpg" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\background.jpg" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

Some generated files are not rendered by default. Learn more.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -13,7 +13,7 @@ namespace ExpenseTracker
{
InitializeComponent();


/*if (!string.IsNullOrEmpty(Preferences.Get("MyFirebaseRefreshToken", "")))
{
MainPage = new NavigationPage(new Home());
@@ -22,9 +22,9 @@ namespace ExpenseTracker
{
MainPage = new NavigationPage(new LoginPage());
}*/
// MainPage = new NavigationPage(new LoginPage());

MainPage = new HomePage();
// MainPage = new NavigationPage(new LoginPage());
MainPage = new NavigationPage(new LoginPage());
// MainPage = new HomePage();
//MainPage = Navigat new LoginPage();
//MainPage = new MainPage();
}
@@ -4,6 +4,7 @@ using System.Text;

namespace ExpenseTracker.model
{
//this class contains constant elements that will be used throughout the app
public class Constants
{
public static string WebAPIkey = "AIzaSyDWd1vZS-n3PIIyP004w9l4DLPNUr5uEBE";
@@ -4,9 +4,11 @@ using System.Text;

namespace ExpenseTracker.model
{
//this model describes the type of data to be taken for each expense category
public class ExpenseCategory
{
public int id { get; set; }
public string name { get; set; }
public string email { get; set; }
}
}
@@ -4,12 +4,14 @@ using System.Text;

namespace ExpenseTracker.model
{
//describes the type of data to be taken for expenses per user
class Expense
{
public int expenseCategory { get; set; }
public string id { get; set; }
public double amount { get; set; }
public string email { get; set; }
public string narration { get; set; }

}
}
@@ -15,46 +15,48 @@ namespace ExpenseTracker.viewModel
FirebaseClient firebase = new FirebaseClient("https://expensetracker-cdaa4.firebaseio.com");

//get all Expenses
public async Task<List<Expense>> GetAllExpense()
public async Task<List<Expense>> GetAllExpense(String usermail)
{

return (await firebase
.Child("Expenses")
.OnceAsync<Expense>()).Select(item => new Expense
.OnceAsync<Expense>()).Where(a=>a.Object.email==usermail).Select(item => new Expense
{
expenseCategory = item.Object.expenseCategory,
narration = item.Object.narration,
amount=item.Object.amount,
id=item.Object.id,
email=item.Object.email,


}).Reverse().ToList();
}
//all New Expense
public async Task AddExpense(double amount, string narration, int expenseCategory, string id)
public async Task AddExpense(double amount, string narration, int expenseCategory, string id, String email)
{

await firebase
.Child("Expenses")
.PostAsync(new Expense() {
amount = amount,
expenseCategory= expenseCategory,
narration = narration,
narration= narration,
id= id,
email=email,
});
}

//get Details of a particular expense
public async Task<Expense> GetExpense(string expenseID)
public async Task<Expense> GetExpense(string expenseID, String email)
{
var allExpense = await GetAllExpense();
var allExpense = await GetAllExpense(email);
await firebase
.Child("Expenses")
.OnceAsync<Expense>();
return allExpense.Where(a => a.id == expenseID).FirstOrDefault();
}

//Update and Expense
//Update an Expense
public async Task UpdateExpense(double amount, string narration, int expenseCategory, string id)
{
var toUpdatePerson = (await firebase
@@ -88,20 +90,20 @@ namespace ExpenseTracker.viewModel


//get all categories
public async Task<List<ExpenseCategory>> GetAllCategory()
public async Task<List<ExpenseCategory>> GetAllCategory(String useremail)
{

return (await firebase
.Child("Category")
.OnceAsync<ExpenseCategory>()).Select(item => new ExpenseCategory
.OnceAsync<ExpenseCategory>()).Where(a => a.Object.email == useremail).Select(item => new ExpenseCategory
{
id = item.Object.id,
name= item.Object.name,

}).ToList();
}
//add new category
public async Task AddCategory(int id, string name)
public async Task AddCategory(int id, string name, string email)
{

await firebase
@@ -111,12 +113,13 @@ namespace ExpenseTracker.viewModel

name=name,
id = id,
email= email
});
}
//get a new category
public async Task<ExpenseCategory> GetCategory(int categoryID)
public async Task<ExpenseCategory> GetCategory(int categoryID, string email)
{
var allExpense = await GetAllCategory();
var allExpense = await GetAllCategory(email);
await firebase
.Child("Category")
.OnceAsync<ExpenseCategory>();
@@ -153,10 +156,10 @@ namespace ExpenseTracker.viewModel


//getting total amount of expenses
public async Task<double> GetTotalAmountOfExpense()
public async Task<double> GetTotalAmountOfExpense(string email)
{
double totalAmount=0.0;
var allExpense = await GetAllExpense();
var allExpense = await GetAllExpense(email);
for (int i= 0; i< allExpense.Count;i++)
{
totalAmount += allExpense[i].amount;
@@ -168,11 +171,11 @@ namespace ExpenseTracker.viewModel


//get total amount spent on each category
public async Task<List<CatergoryAmount>> GetTotalAmountOfExpensePerCategory()
public async Task<List<CatergoryAmount>> GetTotalAmountOfExpensePerCategory(string email)
{
List<CatergoryAmount> categoryAmount = new List<CatergoryAmount>();
var allCategories = await GetAllCategory();
var allExpense = await GetAllExpense();
var allCategories = await GetAllCategory(email);
var allExpense = await GetAllExpense(email);
foreach (var category in allCategories) // Outer loop
{
// Code that should run for each collection

0 comments on commit 25c60a7

Please sign in to comment.