163 lines
4.5 KiB
C#
163 lines
4.5 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="UserProfilModel.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>23.07.2013</sience>
|
|
//----------------------------------------------------------------------
|
|
namespace CampusAppWP8.Model.Setting
|
|
{
|
|
using System.Xml.Serialization;
|
|
using CampusAppWP8.Resources;
|
|
using CampusAppWPortalLib8.Model.Settings;
|
|
|
|
/// <summary>
|
|
/// Model for the profile of an user
|
|
/// </summary>
|
|
[XmlRoot("root")]
|
|
public class UserProfilModel
|
|
{
|
|
#region Members
|
|
|
|
/// <summary>
|
|
/// constant for the first validate semester
|
|
/// </summary>
|
|
private static readonly int FirstSemester = int.Parse(Constants.Valid_FirstSemseter);
|
|
|
|
/// <summary>
|
|
/// constant for the last validate semester
|
|
/// </summary>
|
|
private static readonly int LastSemester = int.Parse(Constants.Valid_LastSemseter);
|
|
|
|
/// <summary>
|
|
/// constant for the max. number of a validate course
|
|
/// </summary>
|
|
private static readonly int MaxCourseNumber = int.Parse(Constants.Valid_MaxCourseNumber);
|
|
|
|
#endregion
|
|
|
|
#region Proberties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the course of the user
|
|
/// </summary>
|
|
public int Course
|
|
{
|
|
get
|
|
{
|
|
return App.LoadFromAppState<int>(Constants.UserSettings_Course);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.ValditateCourse(value))
|
|
{
|
|
App.SaveToAppState<int>(Constants.UserSettings_Course, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the defaultCampus of the user
|
|
/// </summary>
|
|
public Campus DefaultCampus
|
|
{
|
|
get
|
|
{
|
|
return App.LoadFromAppState<Campus>(Constants.UserSettings_DefaultCampus);
|
|
}
|
|
|
|
set
|
|
{
|
|
App.SaveToAppState<Campus>(Constants.UserSettings_DefaultCampus, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the role of the user
|
|
/// </summary>
|
|
public RoleType Role
|
|
{
|
|
get
|
|
{
|
|
return App.LoadFromAppState<RoleType>(Constants.UserSettings_Role);
|
|
}
|
|
|
|
set
|
|
{
|
|
App.SaveToAppState<RoleType>(Constants.UserSettings_Role, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the degree of the user
|
|
/// </summary>
|
|
public DegreeType Degree
|
|
{
|
|
get
|
|
{
|
|
return App.LoadFromAppState<DegreeType>(Constants.UserSettings_Degree);
|
|
}
|
|
|
|
set
|
|
{
|
|
App.SaveToAppState<DegreeType>(Constants.UserSettings_Degree, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the semester of the user
|
|
/// </summary>
|
|
public int Semester
|
|
{
|
|
get
|
|
{
|
|
return App.LoadFromAppState<int>(Constants.UserSettings_Semester);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.ValditateSemester(value))
|
|
{
|
|
App.SaveToAppState<int>(Constants.UserSettings_Semester, value);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Methods check if a value could be a valid semester
|
|
/// </summary>
|
|
/// <param name="possibleSemester">value which has to be checked</param>
|
|
/// <returns>true if it is an valid semester, otherwise false</returns>
|
|
private bool ValditateSemester(int possibleSemester)
|
|
{
|
|
if (possibleSemester < UserProfilModel.FirstSemester || possibleSemester > UserProfilModel.LastSemester)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Methods check if a value could be a valid course
|
|
/// </summary>
|
|
/// <param name="possibleCourse">value which has to be checked</param>
|
|
/// <returns>true if it is an valid course, otherwise false</returns>
|
|
private bool ValditateCourse(int possibleCourse)
|
|
{
|
|
if (possibleCourse > UserProfilModel.MaxCourseNumber)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|