diff --git a/HarPadRee.sln b/HarPadRee.sln
new file mode 100644
index 0000000..79560ec
--- /dev/null
+++ b/HarPadRee.sln
@@ -0,0 +1,83 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29709.97
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HarPadRee.Android", "HarPadRee.Android\HarPadRee.Android.csproj", "{C885C007-B815-476B-9EC1-92DF2C9AE53B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HarPadRee.iOS", "HarPadRee.iOS\HarPadRee.iOS.csproj", "{916F00D6-588B-4960-9650-4CB67BC3EAE9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HarPadRee", "HarPadRee\HarPadRee.csproj", "{B4DC60DC-8557-4F97-B6AC-9E6098D1112C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|iPhone = Debug|iPhone
+ Debug|iPhoneSimulator = Debug|iPhoneSimulator
+ Release|Any CPU = Release|Any CPU
+ Release|iPhone = Release|iPhone
+ Release|iPhoneSimulator = Release|iPhoneSimulator
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|iPhone.Deploy.0 = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|iPhone.Build.0 = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|iPhone.Deploy.0 = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {C885C007-B815-476B-9EC1-92DF2C9AE53B}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|Any CPU.Deploy.0 = Debug|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|iPhone.ActiveCfg = Debug|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|iPhone.Build.0 = Debug|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|iPhone.Deploy.0 = Debug|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Debug|iPhoneSimulator.Deploy.0 = Debug|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|Any CPU.ActiveCfg = Release|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|Any CPU.Build.0 = Release|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|Any CPU.Deploy.0 = Release|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|iPhone.ActiveCfg = Release|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|iPhone.Build.0 = Release|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|iPhone.Deploy.0 = Release|iPhone
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ {916F00D6-588B-4960-9650-4CB67BC3EAE9}.Release|iPhoneSimulator.Deploy.0 = Release|iPhoneSimulator
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|iPhone.Deploy.0 = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|iPhone.Build.0 = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|iPhone.Deploy.0 = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {B4DC60DC-8557-4F97-B6AC-9E6098D1112C}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {19FEF620-594A-4452-AFAB-B2420240C521}
+ EndGlobalSection
+EndGlobal
diff --git a/HarPadRee/App.xaml b/HarPadRee/App.xaml
new file mode 100644
index 0000000..4155a5d
--- /dev/null
+++ b/HarPadRee/App.xaml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/App.xaml.cs b/HarPadRee/App.xaml.cs
new file mode 100644
index 0000000..633852f
--- /dev/null
+++ b/HarPadRee/App.xaml.cs
@@ -0,0 +1,45 @@
+using System;
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace HarPadRee
+{
+ public partial class App : Application
+ {
+ string dbPath => FileAccessHelper.GetLocalFilePath("Cars.db3");
+
+ public static AccountsRepository AccRepo { get; private set; }
+ public static CarRepository CarRepo { get; private set; }
+ public static MillageRepository MillageRepo { get; private set; }
+ public static ServicesRepository ServicesRepo { get; private set; }
+
+ public App()
+ {
+ InitializeComponent();
+ AccRepo = new AccountsRepository(dbPath);
+ CarRepo = new CarRepository(dbPath);
+ MillageRepo = new MillageRepository(dbPath);
+ ServicesRepo = new ServicesRepository(dbPath);
+ MainPage = new MainPage();
+ }
+
+ protected override void OnStart()
+ {
+ if (Application.Current.Properties.ContainsKey("LoggedIn"))
+ {
+ if (App.Current.Properties["LoggedIn"].Equals(true))
+ {
+ App.Current.MainPage = new NavigationPage(new CarsPage((int)App.Current.Properties["AccID"]));
+ }
+ }
+ }
+
+ protected override void OnSleep()
+ {
+ }
+
+ protected override void OnResume()
+ {
+ }
+ }
+}
diff --git a/HarPadRee/AssemblyInfo.cs b/HarPadRee/AssemblyInfo.cs
new file mode 100644
index 0000000..c859952
--- /dev/null
+++ b/HarPadRee/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using Xamarin.Forms.Xaml;
+
+[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
\ No newline at end of file
diff --git a/HarPadRee/CustomControls/ExtendedViewCell.cs b/HarPadRee/CustomControls/ExtendedViewCell.cs
new file mode 100644
index 0000000..7d239aa
--- /dev/null
+++ b/HarPadRee/CustomControls/ExtendedViewCell.cs
@@ -0,0 +1,19 @@
+using Xamarin.Forms;
+
+namespace HarPadRee.CustomControls
+{
+ public class ExtendedViewCell : ViewCell
+ {
+ public static readonly BindableProperty SelectedBackgroundColorProperty =
+ BindableProperty.Create("SelectedBackgroundColor",
+ typeof(Color),
+ typeof(ExtendedViewCell),
+ Color.Default);
+
+ public Color SelectedBackgroundColor
+ {
+ get { return (Color)GetValue(SelectedBackgroundColorProperty); }
+ set { SetValue(SelectedBackgroundColorProperty, value); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/HarPadRee/EncryptHash/Crypto.cs b/HarPadRee/EncryptHash/Crypto.cs
new file mode 100644
index 0000000..4b2234b
--- /dev/null
+++ b/HarPadRee/EncryptHash/Crypto.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HarPadRee
+{
+ public static class Crypto
+ {
+ ///
+ /// hashed the password usng SHA256
+ ///
+ /// returned the hashed password
+ ///
+ public static string Hash(string value)
+ {
+ return Convert.ToBase64String(
+ System.Security.Cryptography.SHA256.Create()
+ .ComputeHash(Encoding.UTF8.GetBytes(value))
+ );
+ }
+ }
+}
diff --git a/HarPadRee/EncryptHash/EncriptionEngine.cs b/HarPadRee/EncryptHash/EncriptionEngine.cs
new file mode 100644
index 0000000..f91a6ee
--- /dev/null
+++ b/HarPadRee/EncryptHash/EncriptionEngine.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HarPadRee
+{
+ public class EncriptionEngine
+ {
+ ///
+ /// encrypts the string
+ ///
+ /// the string to be encrypted
+ /// encrypted string
+ public static string Encrypt(string input)
+ {
+ byte[] inputArray = UTF8Encoding.UTF8.GetBytes(input);
+ TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
+ tripleDES.Key = UTF8Encoding.UTF8.GetBytes("halw-3hq8-sq2219");
+ tripleDES.Mode = CipherMode.ECB;
+ tripleDES.Padding = PaddingMode.PKCS7;
+ ICryptoTransform cTransform = tripleDES.CreateEncryptor();
+ byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
+ tripleDES.Clear();
+ return Convert.ToBase64String(resultArray, 0, resultArray.Length);
+ }
+ ///
+ /// decrypted the string
+ ///
+ /// the string to be decrypted
+ /// decrypted string
+ public static string Decrypt(string input)
+ {
+ byte[] inputArray = Convert.FromBase64String(input);
+ TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
+ tripleDES.Key = UTF8Encoding.UTF8.GetBytes("halw-3hq8-sq2219");
+ tripleDES.Mode = CipherMode.ECB;
+ tripleDES.Padding = PaddingMode.PKCS7;
+ ICryptoTransform cTransform = tripleDES.CreateDecryptor();
+ byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
+ tripleDES.Clear();
+ return UTF8Encoding.UTF8.GetString(resultArray);
+ }
+ }
+}
diff --git a/HarPadRee/FileAccessHelper.cs b/HarPadRee/FileAccessHelper.cs
new file mode 100644
index 0000000..6dc8c90
--- /dev/null
+++ b/HarPadRee/FileAccessHelper.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Xamarin.Essentials;
+
+namespace HarPadRee
+{
+ class FileAccessHelper
+ {
+ public static string GetLocalFilePath(string filename)
+ {
+ return System.IO.Path.Combine(FileSystem.AppDataDirectory, filename);
+ }
+ }
+}
diff --git a/HarPadRee/HarPadRee.csproj b/HarPadRee/HarPadRee.csproj
new file mode 100644
index 0000000..38b6985
--- /dev/null
+++ b/HarPadRee/HarPadRee.csproj
@@ -0,0 +1,51 @@
+
+
+
+ netstandard2.0
+ true
+
+
+
+ portable
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.ComponentModel.DataAnnotations.dll
+
+
+
+
+
+ AddPage.xaml
+
+
+
+
+
+ MSBuild:UpdateDesignTimeXaml
+
+
+ MSBuild:UpdateDesignTimeXaml
+
+
+ MSBuild:UpdateDesignTimeXaml
+
+
+ MSBuild:UpdateDesignTimeXaml
+
+
+ MSBuild:UpdateDesignTimeXaml
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/MillagePage.xaml b/HarPadRee/MillagePage.xaml
new file mode 100644
index 0000000..49d7c81
--- /dev/null
+++ b/HarPadRee/MillagePage.xaml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/MillagePage.xaml.cs b/HarPadRee/MillagePage.xaml.cs
new file mode 100644
index 0000000..be2dc99
--- /dev/null
+++ b/HarPadRee/MillagePage.xaml.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+using HarPadRee.Models;
+namespace HarPadRee
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class MillagePage : ContentPage
+ {
+ int ID;
+ public MillagePage(int CarID, string CarName)
+ {
+ InitializeComponent();
+ Title = CarName + " Services";
+ ID = CarID;
+
+ List millage = App.MillageRepo.GetAllMillage(ID);
+ MillageList.ItemsSource = millage;
+
+ MessagingCenter.Subscribe((App)Application.Current, "UpdateMillage", (sender) =>
+ {
+ UpdateListview();
+ });
+ }
+
+ private void AddBtn_Clicked(object sender, EventArgs e)
+ {
+ Navigation.PushAsync(new AddPage(2, ID));
+ }
+ private void UpdateListview()
+ {
+ List millage = App.MillageRepo.GetAllMillage(ID);
+ MillageList.ItemsSource = millage;
+ }
+ }
+}
\ No newline at end of file
diff --git a/HarPadRee/Models/Models.cs b/HarPadRee/Models/Models.cs
new file mode 100644
index 0000000..ba6c7f1
--- /dev/null
+++ b/HarPadRee/Models/Models.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using SQLite;
+using System.ComponentModel.DataAnnotations;
+using MaxLengthAttribute = SQLite.MaxLengthAttribute;
+namespace HarPadRee.Models
+{
+ public class AccountsModel
+ {
+ [PrimaryKey, AutoIncrement]
+ public int Id { get; set; }
+ [MaxLength(250), Unique]
+ public string Username { get; set; }
+ [MaxLength(250)]
+ public string Password { get; set; }
+ }
+ public class CarsModel
+ {
+ [PrimaryKey, AutoIncrement]
+ public int Id { get; set; }
+
+ public int AccId { get; set; }
+
+ [MaxLength(250)]
+ public string Carname { get; set; }
+
+ public string Average { get; set; }
+
+ }
+ public class ServicesModel
+ {
+ [PrimaryKey, AutoIncrement]
+ public int Id { get; set; }
+
+ public int CarId { get; set; }
+
+ [DataType(DataType.Date)]
+ [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
+ public DateTime? Date { get; set; }
+
+ [MaxLength(250)]
+ public string Service { get; set; }
+ public int Cost { get; set; }
+
+ }
+ public class MilleageModel
+ {
+ [PrimaryKey, AutoIncrement]
+ public int Id { get; set; }
+
+ public int CarId { get; set; }
+
+ [DataType(DataType.Date)]
+ [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
+ public DateTime? Date { get; set; }
+
+ public int Miles { get; set; }
+ public int Litres { get; set; }
+
+ }
+}
diff --git a/HarPadRee/Pages/AddPage.xaml b/HarPadRee/Pages/AddPage.xaml
new file mode 100644
index 0000000..2ff6ea5
--- /dev/null
+++ b/HarPadRee/Pages/AddPage.xaml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/Pages/AddPage.xaml.cs b/HarPadRee/Pages/AddPage.xaml.cs
new file mode 100644
index 0000000..7511455
--- /dev/null
+++ b/HarPadRee/Pages/AddPage.xaml.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+using HarPadRee.Models;
+
+namespace HarPadRee
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class AddPage : ContentPage
+ {
+ int ID;
+ public AddPage(int option,int Id)
+ {
+ InitializeComponent();
+ ID = Id;
+ switch (option)
+ {
+ case 0:
+ Title = "Add New Car";
+ CarOption.IsVisible = true;
+ break;
+ case 1:
+ Title = "Add New Service";
+ ServiceOption.IsVisible = true;
+ break;
+ case 2:
+ Title = "Add New Millage";
+ MillageOption.IsVisible = true;
+ break;
+ }
+ }
+
+ private void AddCarBtn_Clicked(object sender, EventArgs e)
+ {
+ var car = new CarsModel { AccId = ID, Carname = CarNameField.Text };
+ App.CarRepo.AddCar(car);
+ MessagingCenter.Send < App > ((App)Application.Current, "UpdateCars");
+ Navigation.PopAsync();
+
+ }
+
+ private void AddServiceBtn_Clicked(object sender, EventArgs e)
+ {
+ var service = new ServicesModel { CarId = ID, Service = ServiceNameField.Text, Cost = int.Parse(ServiceCostField.Text), Date = DateTime.Now };
+ App.ServicesRepo.AddService(service);
+ MessagingCenter.Send((App)Application.Current, "UpdateServices");
+ Navigation.PopAsync();
+ }
+
+ private void AddMillageBtn_Clicked(object sender, EventArgs e)
+ {
+ var millage = new MilleageModel { CarId = ID, Miles = int.Parse(MilesField.Text), Litres = int.Parse(LitresField.Text), Date = DateTime.Now };
+ App.MillageRepo.AddMillage(millage);
+ MessagingCenter.Send((App)Application.Current, "UpdateMillage");
+ MessagingCenter.Send((App)Application.Current, "UpdateCars");
+ Navigation.PopAsync();
+ }
+ }
+}
\ No newline at end of file
diff --git a/HarPadRee/Pages/CarPage.xaml b/HarPadRee/Pages/CarPage.xaml
new file mode 100644
index 0000000..642c6f6
--- /dev/null
+++ b/HarPadRee/Pages/CarPage.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/Pages/CarPage.xaml.cs b/HarPadRee/Pages/CarPage.xaml.cs
new file mode 100644
index 0000000..ac62765
--- /dev/null
+++ b/HarPadRee/Pages/CarPage.xaml.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace HarPadRee
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class CarPage : ContentPage
+ {
+ string carname;
+ int CarID;
+ public CarPage(string CarName, int CarId)
+ {
+ InitializeComponent();
+ Title = CarName;
+ CarID = CarId;
+ carname = CarName;
+ }
+
+ private void ServicesBtn_Clicked(object sender, EventArgs e)
+ {
+ Navigation.PushAsync(new ServicesPage(CarID, carname));
+ }
+
+ private void MillageBtn_Clicked(object sender, EventArgs e)
+ {
+ Navigation.PushAsync(new MillagePage(CarID, carname));
+ }
+ }
+}
\ No newline at end of file
diff --git a/HarPadRee/Pages/CarsPage.xaml b/HarPadRee/Pages/CarsPage.xaml
new file mode 100644
index 0000000..666b6b9
--- /dev/null
+++ b/HarPadRee/Pages/CarsPage.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/Pages/CarsPage.xaml.cs b/HarPadRee/Pages/CarsPage.xaml.cs
new file mode 100644
index 0000000..5d7105a
--- /dev/null
+++ b/HarPadRee/Pages/CarsPage.xaml.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+using HarPadRee.Models;
+using Xamarin.Forms.Xaml;
+
+namespace HarPadRee
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class CarsPage : ContentPage
+ {
+ int AccountId;
+ public CarsPage(int AccId)
+ {
+ InitializeComponent();
+ List cars = App.CarRepo.GetAllCars(AccId);
+ CarsList.ItemsSource = cars;
+
+ AccountId = AccId;
+ MessagingCenter.Subscribe((App)Application.Current, "UpdateCars", (sender) => {
+ UpdateListview();
+ });
+ }
+
+ private void AddBtn_Clicked(object sender, EventArgs e)
+ {
+ Navigation.PushAsync(new AddPage(0,AccountId));
+ //App.Current.MainPage = new NavigationPage(new AddCarPage());
+
+ }
+ public void UpdateListview()
+ {
+ List cars = App.CarRepo.GetAllCars(AccountId);
+ CarsList.ItemsSource = cars;
+ }
+
+ private void CarsList_ItemTapped(object sender, ItemTappedEventArgs e)
+ {
+ var car = e.Item as CarsModel;
+ Navigation.PushAsync(new CarPage(car.Carname, car.Id));
+ }
+
+ private void Logout_Clicked(object sender, EventArgs e)
+ {
+ App.Current.Properties["LoggedIn"] = false;
+ App.Current.Properties["AccID"] = -1;
+ App.Current.MainPage = new MainPage();
+ }
+ }
+}
\ No newline at end of file
diff --git a/HarPadRee/Pages/MainPage.xaml b/HarPadRee/Pages/MainPage.xaml
new file mode 100644
index 0000000..3f58fea
--- /dev/null
+++ b/HarPadRee/Pages/MainPage.xaml
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HarPadRee/Pages/MainPage.xaml.cs b/HarPadRee/Pages/MainPage.xaml.cs
new file mode 100644
index 0000000..a8914da
--- /dev/null
+++ b/HarPadRee/Pages/MainPage.xaml.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+using HarPadRee.Models;
+
+namespace HarPadRee
+{
+ // Learn more about making custom code visible in the Xamarin.Forms previewer
+ // by visiting https://aka.ms/xamarinforms-previewer
+ [DesignTimeVisible(false)]
+ public partial class MainPage : ContentPage
+ {
+
+ public MainPage()
+ {
+ InitializeComponent();
+ LoginPage.IsVisible = true;
+ }
+
+ private void RegisterLinkBtn(object sender, EventArgs e)
+ {
+ LoginPage.IsVisible = false;
+ RegisterPage.IsVisible = true;
+ }
+
+ private void LoginBtn_Clicked(object sender, EventArgs e)
+ {
+ var acc = App.AccRepo.GetAcc(EncriptionEngine.Encrypt(UsernameField.Text));
+ if(Crypto.Hash(PasswordField.Text) == acc.Password)
+ {
+ if(StaySigned.IsChecked)
+ {
+ App.Current.Properties["LoggedIn"] = true;
+ App.Current.Properties["AccID"] = acc.Id;
+ }
+ App.Current.MainPage = new NavigationPage(new CarsPage(acc.Id));
+
+ }
+ }
+
+ private void LoginLinkBtn(object sender, EventArgs e)
+ {
+ RegisterPage.IsVisible = false;
+ LoginPage.IsVisible = true;
+ }
+
+ private void RegisterBtn_Clicked(object sender, EventArgs e)
+ {
+ if (RegPasswordField.Text == RePasswordField.Text)
+ {
+ var acc = new AccountsModel { Username = EncriptionEngine.Encrypt(RegUsernameField.Text), Password = Crypto.Hash(RePasswordField.Text) };
+ App.AccRepo.Register(acc);
+ RegisterPage.IsVisible = false;
+ LoginPage.IsVisible = true;
+
+ }
+ else
+ {
+ ErrorMsg.Text = "Passwords do not match";
+ }
+ }
+
+ private void ResetMsg(object sender, EventArgs e)
+ {
+ ErrorMsg.Text = "";
+ }
+ }
+}
diff --git a/HarPadRee/Pages/ServicesPage.xaml b/HarPadRee/Pages/ServicesPage.xaml
new file mode 100644
index 0000000..e9d924b
--- /dev/null
+++ b/HarPadRee/Pages/ServicesPage.xaml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HarPadRee/Pages/ServicesPage.xaml.cs b/HarPadRee/Pages/ServicesPage.xaml.cs
new file mode 100644
index 0000000..cf571b5
--- /dev/null
+++ b/HarPadRee/Pages/ServicesPage.xaml.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+using HarPadRee.Models;
+
+namespace HarPadRee
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class ServicesPage : ContentPage
+ {
+ int ID;
+ public ServicesPage(int CarID, string CarName)
+ {
+ InitializeComponent();
+ Title = CarName + " Services";
+ ID = CarID;
+
+ List services = App.ServicesRepo.GetAllServices(CarID);
+ ServicesList.ItemsSource = services;
+
+ MessagingCenter.Subscribe((App)Application.Current, "UpdateServices", (sender) => {
+ UpdateListview();
+ });
+ }
+
+ private void AddBtn_Clicked(object sender, EventArgs e)
+ {
+ Navigation.PushAsync(new AddPage(1, ID));
+ }
+ private void UpdateListview()
+ {
+ List services = App.ServicesRepo.GetAllServices(ID);
+ ServicesList.ItemsSource = services;
+ }
+ }
+}
\ No newline at end of file
diff --git a/HarPadRee/ReadMe.txt b/HarPadRee/ReadMe.txt
new file mode 100644
index 0000000..3691570
--- /dev/null
+++ b/HarPadRee/ReadMe.txt
@@ -0,0 +1,3 @@
+Page Folder - contains all the pages of the application
+Models Folder - contains all the entities of the application
+Repos Folder - contains all the repository logic
\ No newline at end of file
diff --git a/HarPadRee/Repos/AccountsRepository.cs b/HarPadRee/Repos/AccountsRepository.cs
new file mode 100644
index 0000000..2e3b07c
--- /dev/null
+++ b/HarPadRee/Repos/AccountsRepository.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HarPadRee.Models;
+using SQLite;
+
+namespace HarPadRee
+{
+
+ public class AccountsRepository
+ {
+ SQLiteConnection conn;
+ public string StatusMessage { get; set; }
+ public AccountsRepository(string dbPath)
+ {
+ conn = new SQLiteConnection(dbPath);
+ conn.CreateTable();
+
+ }
+
+ public void Register(AccountsModel acc)
+ {
+ int result = 0;
+ try
+ {
+ //basic validation to ensure a name was entered
+ if (string.IsNullOrEmpty(acc.Username))
+ throw new Exception("Valid username required");
+ if (string.IsNullOrEmpty(acc.Password))
+ throw new Exception("Valid password required");
+ result = conn.Insert(new AccountsModel { Username = acc.Username, Password = acc.Password });
+
+ StatusMessage = string.Format("{0} record(s) added [Name: {1})", result, acc.Username);
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to add {0}. Error: {1}", acc.Username, ex.Message);
+ }
+ }
+
+ public AccountsModel GetAcc(string username)
+ {
+ var acc = from a in conn.Table()
+ where a.Username == username
+ select a;
+ return acc.FirstOrDefault();
+ }
+ }
+}
diff --git a/HarPadRee/Repos/CarRepository.cs b/HarPadRee/Repos/CarRepository.cs
new file mode 100644
index 0000000..a38c7f4
--- /dev/null
+++ b/HarPadRee/Repos/CarRepository.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HarPadRee.Models;
+using SQLite;
+namespace HarPadRee
+{
+ public class CarRepository
+ {
+ SQLiteConnection conn;
+ public string StatusMessage { get; set; }
+
+ public CarRepository(string dbPath)
+ {
+ conn = new SQLiteConnection(dbPath);
+ conn.CreateTable();
+
+ }
+
+
+ public void AddCar( CarsModel car)
+ {
+ int result = 0;
+ try
+ {
+ //basic validation to ensure a name was entered
+ if (string.IsNullOrEmpty(car.Carname))
+ throw new Exception("Valid car name required");
+ result = conn.Insert(new CarsModel { AccId = car.AccId, Carname = car.Carname , Average = "N/A"});
+
+ StatusMessage = string.Format("{0} record(s) added [Name: {1})", result, car.Carname);
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to add {0}. Error: {1}", car.Carname, ex.Message);
+ }
+ }
+
+ public void UpdateAverage(int CarID, string Value)
+ {
+ try
+ {
+ var car = conn.Table()
+ .Where(x => x.Id == CarID)
+ .FirstOrDefault();
+ // change something in the object
+ car.Average = Value;
+ conn.Update(car);
+
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to update. {0}", ex.Message);
+ }
+ }
+
+ public List GetAllCars(int AccId)
+ {
+ List AllCars = new List();
+ try
+ {
+ var cars = from c in conn.Table()
+ where c.AccId == AccId
+ select c;
+ foreach(var car in cars)
+ {
+ AllCars.Add(car);
+ }
+
+ return AllCars;
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to retrieve data. {0}", ex.Message);
+ }
+
+ return AllCars;
+
+ }
+ }
+}
diff --git a/HarPadRee/Repos/MillageRepository.cs b/HarPadRee/Repos/MillageRepository.cs
new file mode 100644
index 0000000..fa7e8d8
--- /dev/null
+++ b/HarPadRee/Repos/MillageRepository.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HarPadRee.Models;
+using SQLite;
+
+namespace HarPadRee
+{
+ public class MillageRepository
+ {
+ SQLiteConnection conn;
+ public string StatusMessage { get; set; }
+ public MillageRepository(string dbPath)
+ {
+ conn = new SQLiteConnection(dbPath);
+ conn.CreateTable();
+
+ }
+
+ public void AddMillage(MilleageModel milleage)
+ {
+ int result = 0;
+ try
+ {
+
+ result = conn.Insert(new MilleageModel { Miles = milleage.Miles, Litres = milleage.Litres, CarId = milleage.CarId, Date = milleage.Date });
+ UpdateAverage(milleage.CarId);
+ StatusMessage = string.Format("{0} record(s) added [Miles: {1})", result, milleage.Miles);
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to add {0}. Error: {1}", milleage.Miles, ex.Message);
+ }
+ }
+ public void UpdateAverage(int CarID)
+ {
+ int TotalLitres = 0;
+ int TotalMiles = 0;
+ List millageList = new List();
+ try
+ {
+ var millages = from m in conn.Table()
+ where m.CarId == CarID
+ select m;
+ foreach (var milleage in millages)
+ {
+ millageList.Add(milleage);
+ }
+
+ foreach (var item in millageList)
+ {
+ TotalLitres += item.Litres;
+ TotalMiles += item.Miles;
+ }
+ decimal Total = (decimal)TotalLitres / TotalMiles;
+ App.CarRepo.UpdateAverage(CarID, decimal.Round(Total, 3, MidpointRounding.AwayFromZero).ToString() + " L/Miles");
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to retrieve data. {0}", ex.Message);
+ }
+ }
+ public List GetAllMillage(int CarID)
+ {
+ List millageList = new List();
+ try
+ {
+ var millages = from m in conn.Table()
+ where m.CarId == CarID
+ select m;
+ foreach (var milleage in millages)
+ {
+ millageList.Add(milleage);
+ }
+
+ return millageList;
+ }
+ catch (Exception ex)
+ {
+
+ StatusMessage = string.Format("Failed to retrieve data. {0}", ex.Message);
+ }
+
+ return millageList;
+
+ }
+ }
+}
diff --git a/HarPadRee/Repos/ServicesRepository.cs b/HarPadRee/Repos/ServicesRepository.cs
new file mode 100644
index 0000000..69b2f24
--- /dev/null
+++ b/HarPadRee/Repos/ServicesRepository.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HarPadRee.Models;
+using SQLite;
+
+namespace HarPadRee
+{
+ public class ServicesRepository
+ {
+ SQLiteConnection conn;
+ public string StatusMessage { get; set; }
+ public ServicesRepository(string dbPath)
+ {
+ conn = new SQLiteConnection(dbPath);
+ conn.CreateTable();
+
+ }
+
+ public void AddService(ServicesModel service)
+ {
+ int result = 0;
+ try
+ {
+
+ result = conn.Insert(new ServicesModel { Service = service.Service, CarId = service.CarId, Date = service.Date, Cost = service.Cost });
+
+ StatusMessage = string.Format("{0} record(s) added [service: {1})", result, service.Service);
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to add {0}. Error: {1}", service.Service, ex.Message);
+ }
+ }
+
+ public List GetAllServices(int CarID)
+ {
+ List serviceList = new List();
+ try
+ {
+ var services = from s in conn.Table()
+ where s.CarId == CarID
+ select s;
+ foreach (var service in services)
+ {
+ serviceList.Add(service);
+ }
+
+ return serviceList;
+ }
+ catch (Exception ex)
+ {
+ StatusMessage = string.Format("Failed to retrieve data. {0}", ex.Message);
+ }
+
+ return serviceList;
+
+ }
+ }
+}