Files
win8phoneApp/CampusAppWP8/CampusAppWPortalLib8/Model/GeoDb/PlaceModel.cs
stubbfel dcff024136 fix docs
2013-10-21 15:14:18 +02:00

194 lines
6.9 KiB
C#

//-----------------------------------------------------------------------
// <copyright file="PlaceModel.cs" company="BTU/IIT">
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>Stubbfel</author>
// <date>15.10.2013</date>
// <summary>Implements the place model class</summary>
//-----------------------------------------------------------------------
namespace CampusAppWPortalLib8.Model.GeoDb
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
/// <summary> Model for a place of the SPSService. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
/// <seealso cref="T:System.IEquatable{CampusAppWP8.Model.GeoDb.PlaceModel}"/>
public class PlaceModel : IEquatable<PlaceModel>
{
#region Property
/// <summary> Gets or sets the placeId. </summary>
/// <value> The identifier of the place. </value>
[XmlAttribute("id")]
public string PlaceId { get; set; }
/// <summary> Gets or sets the id of the "parent" of a place. </summary>
/// <value> The identifier of the parent. </value>
[XmlAttribute("parentId")]
public string ParentId { get; set; }
/// <summary> Gets or sets the ReferencePoint of a place. </summary>
/// <value> The reference point. </value>
[XmlAttribute("refpoint")]
public string RefPoint { get; set; }
/// <summary> Gets or sets the information. </summary>
/// <value> The information. </value>
[XmlElement("placeInformation")]
public ObservableCollection<PlaceInformation> Informations { get; set; }
/// <summary> Gets or sets the services. </summary>
/// <value> The services. </value>
[XmlElement("placeService")]
public ObservableCollection<PlaceService> Services { get; set; }
/// <summary>
/// Gets or sets a string, which is the caption of the place (e.g. for contents of UIElements)
/// </summary>
/// <value> The caption. </value>
public string Caption { get; set; }
#endregion
#region Method
/// <summary> Converts this object to a nfc string. </summary>
/// <remarks> Stubbfel, 21.08.2013. </remarks>
/// <returns> This object as a string. </returns>
public string ToNfcString()
{
string nfcStr = "{\n\"url\":\"http://www.tu-cottbus.de/campusapp\",\n\"pid\":\"" + this.PlaceId + "\",\n\"parent\":\"" + this.ParentId + "\"\n}";
return nfcStr;
}
/// <summary> Tests if this PlaceModel is considered equal to another. </summary>
/// <remarks> Stubbfel, 09.09.2013. </remarks>
/// <param name="other"> The place model to compare to this object. </param>
/// <returns> true if the objects are considered equal, false if they are not. </returns>
public bool Equals(PlaceModel other)
{
if (other.PlaceId.Equals(this.PlaceId))
{
return true;
}
return false;
}
/// <summary> Adds a place information. </summary>
/// <remarks> Stubbfel, 09.09.2013. </remarks>
/// <param name="placeInformations"> The place information. </param>
public void AddPlaceInformations(List<PlaceInformation> placeInformations)
{
foreach (PlaceInformation info in placeInformations)
{
if (this.Informations.Contains(info))
{
int index = this.Informations.IndexOf(info);
this.Informations[index].InformationValue = info.InformationValue;
}
else
{
this.Informations.Add(info);
}
}
}
/// <summary> Adds a place services. </summary>
/// <remarks> Stubbfel, 09.09.2013. </remarks>
/// <param name="placeServices"> The place services. </param>
public void AddPlaceServices(List<PlaceService> placeServices)
{
foreach (PlaceService service in placeServices)
{
if (this.Services.Contains(service))
{
int index = this.Services.IndexOf(service);
this.Services[index].Request = service.Request;
this.Services[index].SAP = service.SAP;
}
else
{
this.Services.Add(service);
}
}
}
/// <summary> Query if 'names' contains information names. </summary>
/// <remarks> Stubbfel, 09.09.2013. </remarks>
/// <param name="names"> The names. </param>
/// <returns> true if it succeeds, false if it fails. </returns>
public bool ContainsInformationNames(List<string> names)
{
foreach (string name in names)
{
bool tmpResult = false;
foreach (PlaceInformation info in this.Informations)
{
if (name.Equals(info.InformationName))
{
tmpResult = true;
break;
}
}
if (!tmpResult)
{
return tmpResult;
}
}
return true;
}
/// <summary> Query if 'services' contains service names. </summary>
/// <remarks> Stubbfel, 09.09.2013. </remarks>
/// <param name="services"> The services. </param>
/// <returns> true if it succeeds, false if it fails. </returns>
public bool ContainsServiceNames(List<string> services)
{
foreach (string name in services)
{
bool tmpResult = false;
foreach (PlaceService service in this.Services)
{
if (name.Equals(service.ServiceName))
{
tmpResult = true;
break;
}
}
if (!tmpResult)
{
return tmpResult;
}
}
return true;
}
/// <summary> Method gets the InformationValue of a certain InformationName. </summary>
/// <remarks> Stubbfel, 15.10.2013. </remarks>
/// <param name="key"> string for InformationName. </param>
/// <returns> value of the information. </returns>
public string GetInformationsValue(string key)
{
foreach (PlaceInformation info in this.Informations)
{
if (info.InformationName.Equals(key))
{
return info.InformationValue;
}
}
return null;
}
#endregion
}
}