diff --git a/AppShell.xaml b/AppShell.xaml index 4f87549..37027f6 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -9,8 +9,10 @@ - + + + diff --git a/AppShell.xaml.cs b/AppShell.xaml.cs index 5d609f4..52b9325 100644 --- a/AppShell.xaml.cs +++ b/AppShell.xaml.cs @@ -11,7 +11,7 @@ namespace Justice Routing.RegisterRoute("LoginPage", typeof(Views.LoginPage)); Routing.RegisterRoute("DashboardPage", typeof(Views.DashboardPage)); - Routing.RegisterRoute("ViewReportsPage", typeof(Views.ViewReportsPage)); + Routing.RegisterRoute("ViewReportsPage", typeof(Views.EndUserReportsPage)); LogoutCommand = new Command(async () => { @@ -29,7 +29,7 @@ namespace Justice base.OnNavigating(args); // Check if user is authenticated - if (!AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("ViewReportsPage") || !AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("DashboardPage")) + if (!AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("EndUserReportPage") || !AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("DashboardPage") || !AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("AuthorityReportsPage")) { args.Cancel(); // Prevent navigation await Shell.Current.GoToAsync("//LoginPage"); diff --git a/Helpers/DatabaseHelper.cs b/Helpers/DatabaseHelper.cs index fd883e1..3ae342f 100644 --- a/Helpers/DatabaseHelper.cs +++ b/Helpers/DatabaseHelper.cs @@ -36,6 +36,10 @@ namespace Justice.Helpers { return await _database.DeleteAsync(item); } + public async Task UpdateAsync(T item) where T : new() + { + return await _database.UpdateAsync(item); + } public async Task FindAsync(string query, params object[] args) where T : new() { return await _database.FindWithQueryAsync(query, args); diff --git a/Helpers/EmailService.cs b/Helpers/EmailService.cs index 496d631..77c93ea 100644 --- a/Helpers/EmailService.cs +++ b/Helpers/EmailService.cs @@ -22,7 +22,7 @@ namespace Justice.Services { _incidentTypeToEmail = new Dictionary { - { "Accident", "amreitsyanf@gmail.com" }, + { "Accident", "ambulancemaiti@gmail.com" }, { "Crime", "crime-authority@example.com" }, { "Fire", "fire-department@example.com" }, { "Other", "general-authority@example.com" } diff --git a/Helpers/GeoHelper.cs b/Helpers/GeoHelper.cs index 8c828c7..c5c51c5 100644 --- a/Helpers/GeoHelper.cs +++ b/Helpers/GeoHelper.cs @@ -1,30 +1,28 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Justice.Helpers { - public class GeoHelper + public static class GeoHelper { - public static double CalculateDistance(double latitude1, double longitude1, double latitude2, double longitude2) + public static double CalculateDistance(double lat1, double lon1, double lat2, double lon2) { - double radianLat1 = Math.PI * latitude1 / 100; - double radianLat2 = Math.PI * latitude2 / 100; - double radianLong1 = Math.PI * longitude1 / 100; - double radianLong2 = Math.PI * longitude2 / 100; + const double EarthRadiusKm = 6371; - double dLong = radianLong2 - radianLong1; - double dLat = radianLat2 - radianLat1; - double a = Math.Pow(Math.Sin(dLat / 2), 2) + - Math.Cos(radianLat1) * Math.Cos(radianLat2) * - Math.Pow(Math.Sin(dLong / 2),2); - double c = 2 * Math.Asin(Math.Sqrt(a)); - const double radius = 6371; //radius of earth in kilometer - double distance = radius * c; + double dLat = DegreesToRadians(lat2 - lat1); + double dLon = DegreesToRadians(lon2 - lon1); - return distance; + double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + + Math.Cos(DegreesToRadians(lat1)) * Math.Cos(DegreesToRadians(lat2)) * + Math.Sin(dLon / 2) * Math.Sin(dLon / 2); + + double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); + + return EarthRadiusKm * c; + } + + private static double DegreesToRadians(double degrees) + { + return degrees * Math.PI / 180; } } } diff --git a/Justice.csproj b/Justice.csproj index fbc1f82..e5bdb4f 100644 --- a/Justice.csproj +++ b/Justice.csproj @@ -85,12 +85,18 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile @@ -109,9 +115,6 @@ MSBuild:Compile - - MSBuild:Compile - diff --git a/Justice.csproj.user b/Justice.csproj.user index bc2dc16..fadeb8c 100644 --- a/Justice.csproj.user +++ b/Justice.csproj.user @@ -17,12 +17,18 @@ Designer + + Designer + Designer Designer + + Designer + Designer @@ -41,9 +47,6 @@ Designer - - Designer - diff --git a/Models/Authority.cs b/Models/Authority.cs index a8a4d33..124e5ce 100644 --- a/Models/Authority.cs +++ b/Models/Authority.cs @@ -13,5 +13,6 @@ namespace Justice.Models public double Latitude { get; set; } public double Longitude { get; set; } public string AuthorityType { get; set; } + public string ResponsibleFor { get; set; } } } diff --git a/Models/IncidentReport.cs b/Models/IncidentReport.cs index 57116b2..a2d4a74 100644 --- a/Models/IncidentReport.cs +++ b/Models/IncidentReport.cs @@ -1,4 +1,5 @@ -using SQLite; +using Org.BouncyCastle.Bcpg; +using SQLite; using System; using System.Collections.Generic; using System.Linq; @@ -19,5 +20,7 @@ namespace Justice.Models public string Address { get; set; } public DateTime DateTime { get; set; } public string AttachmentPath { get; set; } + public string Status { get; set; } + public string AssignedAuthority { get; set; } } } diff --git a/Resources/Images/logo.png b/Resources/Images/logo.png new file mode 100644 index 0000000..e1ba3c0 Binary files /dev/null and b/Resources/Images/logo.png differ diff --git a/Services/AuthorityService.cs b/Services/AuthorityService.cs index e9922c4..205ffa4 100644 --- a/Services/AuthorityService.cs +++ b/Services/AuthorityService.cs @@ -16,8 +16,10 @@ namespace Justice.Services new Authority { Name = "Police", Email = "amritsyangtan1@gmail.com", Latitude = 47.7008, Longitude = 60.3000, AuthorityType = "Accident" }, new Authority { Name = "Police", Email = "amreitsyanf@gmail.com", Latitude = 27.7008, Longitude = 85.3000, AuthorityType = "Accident" }, new Authority { Name = "Fire Department", Email = "amAritsyangtan1@gmail.com", Latitude = 27.7110, Longitude = 85.2915, AuthorityType = "Fire" }, + new Authority { Name = "Crime", Email = "amritsyangtan1@gmail.com", Latitude = 47.7110, Longitude = 90.2915, AuthorityType = "Police" }, + new Authority { Name = "Crime", Email = "amreitsyanf@gmail.com", Latitude = 30.7110, Longitude = 80.2915, AuthorityType = "Police" }, new Authority { Name = "Ambulance", Email = "ambulance@example.com", Latitude = 27.7052, Longitude = 85.3092, AuthorityType = "Ambulance" } - }; + }; public List GetNearByAuthorities(double incidentLatitude, double incidentLongitude, double radiusKm = 10) { List nearbyAuthorities = new List(); diff --git a/Views/AuthorityReportsPage.xaml b/Views/AuthorityReportsPage.xaml new file mode 100644 index 0000000..9a4ae7c --- /dev/null +++ b/Views/AuthorityReportsPage.xaml @@ -0,0 +1,37 @@ + + + +