228 lines
5.9 KiB
C#
228 lines
5.9 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;
|
|
|
|
/// <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 Enums
|
|
/// <summary>
|
|
/// Specifies the degrees.
|
|
/// </summary>
|
|
public enum DegreeType
|
|
{
|
|
/// <summary>
|
|
/// bachelor degree
|
|
/// </summary>
|
|
BACHELOR = 82,
|
|
|
|
/// <summary>
|
|
/// master degree
|
|
/// </summary>
|
|
MASTER = 88,
|
|
|
|
/// <summary>
|
|
/// diploma degree
|
|
/// </summary>
|
|
DIPLOM = 11
|
|
}
|
|
|
|
/// <summary>
|
|
/// Specifies the role of the user.
|
|
/// </summary>
|
|
public enum RoleType
|
|
{
|
|
/// <summary>
|
|
/// for students (01).
|
|
/// </summary>
|
|
STUDENT = 1,
|
|
|
|
/// <summary>
|
|
/// for staffs (10).
|
|
/// </summary>
|
|
STAFF = 2,
|
|
}
|
|
|
|
/// <summary>
|
|
/// Specifies the campus of the user.
|
|
/// </summary>
|
|
public enum Campus
|
|
{
|
|
/// <summary>
|
|
/// Cottbus -> MainCampus
|
|
/// </summary>
|
|
CB_MAIN = 1,
|
|
|
|
/// <summary>
|
|
/// Cottbus -> NorthCampus
|
|
/// </summary>
|
|
CB_NORTH = 4,
|
|
|
|
/// <summary>
|
|
/// Cottbus -> SouthCampus
|
|
/// </summary>
|
|
CB_SOUTH = 2,
|
|
|
|
/// <summary>
|
|
/// Senftenberg -> MainCampus
|
|
/// </summary>
|
|
SFB_MAIN = 3
|
|
}
|
|
|
|
#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
|
|
}
|
|
}
|