Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
UEngage/UEngage/Explore.xaml.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
159 lines (121 sloc)
4.38 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
using Xamarin.Essentials; | |
using System.Diagnostics; | |
using UEngage.Models; | |
namespace UEngage | |
{ | |
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class Explore : ContentPage | |
{ | |
List<Report_> res; | |
public Explore() | |
{ | |
InitializeComponent(); | |
} | |
protected override void OnAppearing() | |
{ | |
bindData(); | |
base.OnAppearing(); | |
} | |
private async void bindData() | |
{ | |
res = await App.Database.GetReportsAsync(); | |
var a = res.GroupBy(x => x.reportType); | |
List<issuselist> l = new List<issuselist>(); | |
foreach (var item in a) | |
{ | |
int getcount = res.Where(x => x.reportType == item.Key).Count(); | |
l.Add( new issuselist() { issuecount = getcount, issuename = item.Key }); | |
}; | |
var max = l.OrderByDescending(x => x.issuecount).First(); | |
txtcategory.Text = "Category : " + max.issuename; | |
postcode.Text = "Post Code : " + Constant.loggedUser.Postcode; | |
textreports.Text = "Total Reports : " + max.issuecount.ToString(); | |
List<ReportCopy> list = new List<ReportCopy>(); | |
foreach (var item in res) | |
{ | |
ReportCopy R = new ReportCopy() | |
{ | |
postCode = item.postCode, | |
reportType = item.reportType, | |
Description = item.Description, | |
latitude = item.latitude, | |
Longitude = item.Longitude, | |
imagePath = item.imagePath, | |
ID = item.ID, | |
Date = item.Date, | |
Username = item.Username | |
}; | |
if (item.imagePath != null) | |
{ | |
R.image = ImageSource.FromFile(item.imagePath); | |
} | |
list.Add(R); | |
} | |
listReports.ItemsSource = list; | |
} | |
//public object LabelLocation { get; private set; } | |
private void SearchBar_SearchButtonPressed(object sender, EventArgs e) | |
{ | |
try | |
{ | |
if (txtsearch.Text == "") | |
{ | |
listReports.ItemsSource = res; | |
return; | |
} | |
if (txtsearch.Text != null || txtsearch.Text.Trim() != "") | |
{ | |
var searchedResult = res.Where(x => x.postCode.ToLower().Contains(txtsearch.Text.ToLower()) || x.reportType.ToLower().Contains(txtsearch.Text.ToLower())).ToList(); | |
List<ReportCopy> list = new List<ReportCopy>(); | |
foreach (var item in searchedResult) | |
{ | |
ReportCopy R = new ReportCopy() | |
{ | |
postCode = item.postCode, | |
reportType = item.reportType, | |
Description = item.Description, | |
latitude=item.latitude, | |
Longitude=item.Longitude, | |
imagePath=item.imagePath, | |
ID=item.ID, | |
Date=item.Date, | |
Username=item.Username | |
}; | |
if (item.imagePath != null) | |
{ | |
R.image = ImageSource.FromFile(item.imagePath); | |
} | |
list.Add(R); | |
} | |
listReports.ItemsSource = list; | |
} | |
else | |
{ | |
bindData(); | |
} | |
} | |
catch (Exception ex) | |
{ | |
} | |
} | |
private void TapGestureRecognizer_Tapped(object sender, EventArgs e) | |
{ | |
Grid grid = (Grid)sender; | |
var obb = (ReportCopy)grid.BindingContext; | |
Navigation.PushModalAsync(new DetailModelPage(obb)); | |
} | |
} | |
internal class issuselist | |
{ | |
public string issuename { get; set; } | |
public int issuecount { get; set; } | |
public string postalcode { get; set; } | |
} | |
} |