82 lines
2.6 KiB
C#
82 lines
2.6 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="StudentCouncilListModel.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>02.07.2013</sience>
|
|
//----------------------------------------------------------------------
|
|
namespace CampusAppWPortalLib8.Model.StudentCouncil
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Xml.Serialization;
|
|
|
|
/// <summary>
|
|
/// Model for menus in one week
|
|
/// </summary>
|
|
[XmlRoot("root")]
|
|
public class StudentCouncilListModel
|
|
{
|
|
#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="StudentCouncilListModel" /> class.
|
|
/// </summary>
|
|
public StudentCouncilListModel()
|
|
{
|
|
this.createTime = DateTime.Now;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Proberty
|
|
/// <summary>
|
|
/// Gets or sets the StudentCouncils
|
|
/// </summary>
|
|
[XmlArray("data")]
|
|
[XmlArrayItem("studentcouncil")]
|
|
public ObservableCollection<StudentCouncilModel> StudentCouncils { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the creation time of the model
|
|
/// </summary>
|
|
public DateTime CreateTime
|
|
{
|
|
get
|
|
{
|
|
return this.createTime;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
/// <summary>
|
|
/// Method group the StudentCouncilList by Faculty
|
|
/// </summary>
|
|
/// <returns>a Dictionary, where the Key is name of the Faculty und the value is a List of StudentCouncil</returns>
|
|
public Dictionary<string, List<StudentCouncilModel>> GetStudentCouncilsGroupByFaculty()
|
|
{
|
|
List<IGrouping<string, StudentCouncilModel>> tmpList = this.StudentCouncils.GroupBy(p => p.Faculty).ToList();
|
|
Dictionary<string, List<StudentCouncilModel>> itemMap = new Dictionary<string, List<StudentCouncilModel>>();
|
|
foreach (IGrouping<string, StudentCouncilModel> group in tmpList)
|
|
{
|
|
Dictionary<string, List<StudentCouncilModel>> tempDic = new Dictionary<string, List<StudentCouncilModel>>();
|
|
itemMap.Add(group.Key, group.ToList());
|
|
}
|
|
|
|
return itemMap;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|