270 lines
6.2 KiB
C#
270 lines
6.2 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="MenuModel.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>04.05.2013</sience>
|
|
//----------------------------------------------------------------------
|
|
namespace CampusAppWP8.Model.Mensa
|
|
{
|
|
using System;
|
|
using System.Xml.Serialization;
|
|
using CampusAppWP8.Resources;
|
|
using CampusAppWP8.Utility;
|
|
|
|
/// <summary>
|
|
/// Model for menu
|
|
/// </summary>
|
|
public class MenuModel
|
|
{
|
|
#region Member
|
|
|
|
/// <summary>
|
|
/// Name for bio dinner
|
|
/// </summary>
|
|
private string bio = AppResources.MensaApp_NotToday;
|
|
|
|
/// <summary>
|
|
/// Name for 1. dinner
|
|
/// </summary>
|
|
private string dinner1 = AppResources.MensaApp_NotToday;
|
|
|
|
/// <summary>
|
|
/// Name for 2. dinner
|
|
/// </summary>
|
|
private string dinner2 = AppResources.MensaApp_NotToday;
|
|
|
|
/// <summary>
|
|
/// Name for 3. dinner
|
|
/// </summary>
|
|
private string dinner3 = AppResources.MensaApp_NotToday;
|
|
|
|
/// <summary>
|
|
/// Name for 4. dinner
|
|
/// </summary>
|
|
private string dinner4 = AppResources.MensaApp_NotToday;
|
|
|
|
/// <summary>
|
|
/// Name for action dinner
|
|
/// </summary>
|
|
private string action = AppResources.MensaApp_NotToday;
|
|
|
|
/// <summary>
|
|
/// Name of the day
|
|
/// </summary>
|
|
private string dayName;
|
|
|
|
/// <summary>
|
|
/// DateTime of the day
|
|
/// </summary>
|
|
private DateTime date;
|
|
|
|
/// <summary>
|
|
/// DateTime of the monday
|
|
/// </summary>
|
|
private DateTime monday;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="MenuModel" /> class.
|
|
/// </summary>
|
|
public MenuModel()
|
|
{
|
|
this.monday = MenuWeekModel.CalcFirstWeekDay();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Property
|
|
|
|
/// <summary>
|
|
/// Gets or sets the WeekDay
|
|
/// </summary>
|
|
[XmlElement("Wochentag")]
|
|
public string Day
|
|
{
|
|
get
|
|
{
|
|
return this.dayName;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.dayName);
|
|
this.CalcDateOfDay();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets of Date
|
|
/// </summary>
|
|
public DateTime Date
|
|
{
|
|
get
|
|
{
|
|
return this.date;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != this.date)
|
|
{
|
|
this.date = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets dinner 1
|
|
/// </summary>
|
|
[XmlElement("Essen1")]
|
|
public string Dinner1
|
|
{
|
|
get
|
|
{
|
|
return this.dinner1;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.dinner1);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets dinner 2
|
|
/// </summary>
|
|
[XmlElement("Essen2")]
|
|
public string Dinner2
|
|
{
|
|
get
|
|
{
|
|
return this.dinner2;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.dinner2);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets dinner 3
|
|
/// </summary>
|
|
[XmlElement("Essen3")]
|
|
public string Dinner3
|
|
{
|
|
get
|
|
{
|
|
return this.dinner3;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.dinner3);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets dinner 4
|
|
/// </summary>
|
|
[XmlElement("Essen4")]
|
|
public string Dinner4
|
|
{
|
|
get
|
|
{
|
|
return this.dinner4;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.dinner4);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets dinner bio
|
|
/// </summary>
|
|
[XmlElement("Bio")]
|
|
public string Bio
|
|
{
|
|
get
|
|
{
|
|
return this.bio;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.bio);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets dinner action
|
|
/// </summary>
|
|
[XmlElement("Aktionstag")]
|
|
public string Action
|
|
{
|
|
get
|
|
{
|
|
return this.action;
|
|
}
|
|
|
|
set
|
|
{
|
|
this.SetValue(value, ref this.action);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>
|
|
/// Methods sets the property
|
|
/// </summary>
|
|
/// <remarks> maybe move to base class</remarks>
|
|
/// <param name="value">new property value</param>
|
|
/// <param name="property">name of the property</param>
|
|
private void SetValue(string value, ref string property)
|
|
{
|
|
if (value != null && !string.Empty.Equals(value) && !value.Equals(property))
|
|
{
|
|
property = StringManager.StripHTML(value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Method calculate the DateTime of the MenuDay
|
|
/// </summary>
|
|
private void CalcDateOfDay()
|
|
{
|
|
switch (this.dayName)
|
|
{
|
|
case "Montag":
|
|
this.date = this.monday;
|
|
break;
|
|
case "Diensttag":
|
|
this.date = this.monday.AddDays(1);
|
|
break;
|
|
case "Mittwoch":
|
|
this.date = this.monday.AddDays(2);
|
|
break;
|
|
case "Donnerstag":
|
|
this.date = this.monday.AddDays(3);
|
|
break;
|
|
case "Freitag":
|
|
this.date = this.monday.AddDays(4);
|
|
break;
|
|
default:
|
|
this.date = this.monday;
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|