174 lines
4.5 KiB
C#
174 lines
4.5 KiB
C#
//-----------------------------------------------------------------------------
|
|
// <copyright file="PersonModel.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>05.09.2013</sience>
|
|
//-----------------------------------------------------------------------------
|
|
namespace CampusAppWPortalLib8.Model.Person
|
|
{
|
|
using System.Collections.ObjectModel;
|
|
using System.Xml.Serialization;
|
|
|
|
/// <summary>Person model.</summary>
|
|
/// <remarks>Stubbfel, 05.09.2013.</remarks>
|
|
/// <typeparam name="T">template for the PersonFunction-Class</typeparam>
|
|
public class PersonModel<T> : IPersonModel<T> where T : IPersonFunctionModel
|
|
{
|
|
#region Member
|
|
|
|
/// <summary>The akadgrad.</summary>
|
|
private string akadgrad;
|
|
|
|
/// <summary>Name of the sur.</summary>
|
|
private string surName;
|
|
|
|
/// <summary>The person's first name.</summary>
|
|
private string firstName;
|
|
|
|
/// <summary>The identifier.</summary>
|
|
private string id;
|
|
|
|
/// <summary>The functions.</summary>
|
|
private ObservableCollection<T> functions;
|
|
|
|
#endregion
|
|
|
|
#region Property
|
|
|
|
/// <summary>Gets or sets the identifier.</summary>
|
|
/// <value>The identifier.</value>
|
|
[XmlAttribute("id")]
|
|
public string ID
|
|
{
|
|
get
|
|
{
|
|
return this.id;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.id)
|
|
{
|
|
this.id = value;
|
|
this.SetPersonIdToFunction();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the akadgrad.</summary>
|
|
/// <value>The akadgrad.</value>
|
|
[XmlAttribute("akadgrad")]
|
|
public string Akadgrad
|
|
{
|
|
get
|
|
{
|
|
return this.akadgrad;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.akadgrad)
|
|
{
|
|
this.akadgrad = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the name of the sur.</summary>
|
|
/// <value>The name of the sur.</value>
|
|
[XmlAttribute("nachname")]
|
|
public string SurName
|
|
{
|
|
get
|
|
{
|
|
return this.surName;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.surName)
|
|
{
|
|
this.surName = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the person's first name.</summary>
|
|
/// <value>The name of the first.</value>
|
|
[XmlAttribute("vorname")]
|
|
public string FirstName
|
|
{
|
|
get
|
|
{
|
|
return this.firstName;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.firstName)
|
|
{
|
|
this.firstName = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets the functions of a person.</summary>
|
|
/// <value>The functions.</value>
|
|
[XmlElement("funktion")]
|
|
public ObservableCollection<T> Functions
|
|
{
|
|
get
|
|
{
|
|
return this.functions;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.functions)
|
|
{
|
|
this.functions = value;
|
|
this.SetPersonIdToFunction();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the name of a Person (FirstName SurName).</summary>
|
|
/// <value>The name of a Person.</value>
|
|
public string FullName
|
|
{
|
|
get
|
|
{
|
|
return this.Akadgrad + " " + this.FirstName + " " + this.SurName;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>Sets person identifier to function.</summary>
|
|
/// <remarks>Stubbfel, 05.09.2013.</remarks>
|
|
public void SetPersonIdToFunction()
|
|
{
|
|
if (this.id == null || this.id.Equals(string.Empty) || this.functions == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int index = 0;
|
|
foreach (T item in this.functions)
|
|
{
|
|
IPersonFunctionModel function = item as IPersonFunctionModel;
|
|
if (function != null)
|
|
{
|
|
function.PersonID = this.ID;
|
|
function.FunctionIndex = index++;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|