//----------------------------------------------------------------------- // // Company copyright tag. // // stubbfel // 04.05.2013 //---------------------------------------------------------------------- namespace CampusAppWP8.Model.Mensa { using System; using System.Xml.Serialization; using CampusAppWP8.Resources; using CampusAppWP8.Utility; /// /// Model for menu /// public class MenuModel { #region Member /// /// Name for bio dinner /// private string bio = AppResources.MensaApp_NotToday; /// /// Name for 1. dinner /// private string dinner1 = AppResources.MensaApp_NotToday; /// /// Name for 2. dinner /// private string dinner2 = AppResources.MensaApp_NotToday; /// /// Name for 3. dinner /// private string dinner3 = AppResources.MensaApp_NotToday; /// /// Name for 4. dinner /// private string dinner4 = AppResources.MensaApp_NotToday; /// /// Name for action dinner /// private string action = AppResources.MensaApp_NotToday; /// /// Name of the day /// private string dayName; /// /// DateTime of the day /// private DateTime date; /// /// DateTime of the monday /// private DateTime monday; #endregion #region Constructor /// /// Initializes a new instance of the class. /// public MenuModel() { this.monday = MenuWeekModel.CalcFirstWeekDay(); } #endregion #region Property /// /// Gets or sets the WeekDay /// [XmlElement("Wochentag")] public string Day { get { return this.dayName; } set { this.SetValue(value, ref this.dayName); this.CalcDateOfDay(); } } /// /// Gets or sets of Date /// public DateTime Date { get { return this.date; } set { if (value != this.date) { this.date = value; } } } /// /// Gets or sets dinner 1 /// [XmlElement("Essen1")] public string Dinner1 { get { return this.dinner1; } set { this.SetValue(value, ref this.dinner1); } } /// /// Gets or sets dinner 2 /// [XmlElement("Essen2")] public string Dinner2 { get { return this.dinner2; } set { this.SetValue(value, ref this.dinner2); } } /// /// Gets or sets dinner 3 /// [XmlElement("Essen3")] public string Dinner3 { get { return this.dinner3; } set { this.SetValue(value, ref this.dinner3); } } /// /// Gets or sets dinner 4 /// [XmlElement("Essen4")] public string Dinner4 { get { return this.dinner4; } set { this.SetValue(value, ref this.dinner4); } } /// /// Gets or sets dinner bio /// [XmlElement("Bio")] public string Bio { get { return this.bio; } set { this.SetValue(value, ref this.bio); } } /// /// Gets or sets dinner action /// [XmlElement("Aktionstag")] public string Action { get { return this.action; } set { this.SetValue(value, ref this.action); } } #endregion #region Method /// /// Methods sets the property /// /// maybe move to base class /// new property value /// name of the property private void SetValue(string value, ref string property) { if (value != null && !string.Empty.Equals(value) && !value.Equals(property)) { property = StringManager.StripHTML(value); } } /// /// Method calculate the DateTime of the MenuDay /// 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 } }