//-----------------------------------------------------------------------
//
// Company copyright tag.
//
// stubbfel
// 08.08.2013
//----------------------------------------------------------------------
namespace CampusAppWPortalLib8.Model.GeoDb
{
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml.Serialization;
///
/// Model for a xml-response of the SPSService
///
[XmlRoot("root")]
public class SpsModel
{
/// Initializes a new instance of the SpsModel class.
/// Stubbfel, 20.08.2013.
public SpsModel()
{
this.Places = new ObservableCollection();
}
///
/// Gets or sets a list of places
///
[XmlElement("place")]
public ObservableCollection Places { get; set; }
/// Gets places by information.
/// Stubbfel, 19.08.2013.
/// The query.
/// (Optional) the ignore cases.
/// (Optional) name of the information.
/// The places by information.
public List GetPlacesByInformation(string query, bool ignoreCases = true, string informationName = null)
{
string querryLow = string.Empty;
IEnumerable resultplaces = null;
// select correct statement
if (ignoreCases && informationName == null)
{
querryLow = query.ToLower();
resultplaces = from place in this.Places
from info in place.Informations
where info.InformationValue.ToLower().Contains(querryLow)
select place;
}
else if (ignoreCases && informationName != null)
{
querryLow = query.ToLower();
resultplaces = from place in this.Places
from info in place.Informations
where info.InformationValue.ToLower().Contains(querryLow) && info.InformationName.Equals(informationName)
select place;
}
else if (!ignoreCases && informationName == null)
{
resultplaces = from place in this.Places
from info in place.Informations
where info.InformationValue.Contains(querryLow)
select place;
}
else if (!ignoreCases && informationName != null)
{
resultplaces = from place in this.Places
from info in place.Informations
where info.InformationValue.Contains(querryLow) && info.InformationName.Equals(informationName)
select place;
}
// null assert
if (resultplaces == null)
{
return null;
}
return resultplaces.ToList();
}
}
}