Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
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));
}
}
}