83 lines
2.1 KiB
C#
83 lines
2.1 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="MenuWeekModel.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>03.05.2013</sience>
|
|
//----------------------------------------------------------------------
|
|
namespace CampusAppWP8.Model.Mensa
|
|
{
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Xml.Serialization;
|
|
|
|
/// <summary>
|
|
/// Model for menus in one week
|
|
/// </summary>
|
|
[XmlRoot("root")]
|
|
public class MenuWeekModel
|
|
{
|
|
#region Members
|
|
/// <summary>
|
|
/// Time when the model was created
|
|
/// </summary>
|
|
private readonly DateTime createTime;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="MenuWeekModel" /> class.
|
|
/// </summary>
|
|
public MenuWeekModel()
|
|
{
|
|
this.createTime = DateTime.Now;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Proberty
|
|
|
|
/// <summary>
|
|
/// Gets or sets the menus for the week
|
|
/// </summary>
|
|
[XmlArray("BTU")]
|
|
[XmlArrayItem("Tagesmenu")]
|
|
public ObservableCollection<MenuModel> Menus { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the creation time of the model
|
|
/// </summary>
|
|
public DateTime CreateTime
|
|
{
|
|
get
|
|
{
|
|
return this.createTime;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Method calculate this day of the week, which its gets new menus
|
|
/// </summary>
|
|
/// <returns>Date of NewMenuWeekDay</returns>
|
|
public static DateTime CalcFirstWeekDay()
|
|
{
|
|
DateTime now = DateTime.Now;
|
|
while (now.DayOfWeek != DayOfWeek.Monday)
|
|
{
|
|
now = now.Subtract(new TimeSpan(1, 0, 0, 0));
|
|
}
|
|
|
|
DateTime monday = new DateTime(now.Year, now.Month, now.Day);
|
|
return monday;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|