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/Home.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.
132 lines (104 sloc)
3.7 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 Home : ContentPage | |
{ | |
List<Report_> res; | |
public Home() | |
{ | |
InitializeComponent(); | |
} | |
protected override void OnAppearing() | |
{ | |
bindData(); | |
base.OnAppearing(); | |
} | |
private async void bindData() | |
{ | |
res = await App.Database.GetReportsAsync(); | |
List<ReportCopy> list = new List<ReportCopy>(); | |
foreach (var item in res.Where(x=>x.postCode==Constant.loggedUser.Postcode)) | |
{ | |
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.Where(x => x.postCode == Constant.loggedUser.Postcode)) | |
{ | |
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)); | |
} | |
} | |
} |