sharee.bike-App/TINKLib/Model/State/StateOccupiedInfo.cs
2021-05-13 20:03:07 +02:00

80 lines
2.3 KiB
C#

using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;
namespace TINK.Model.State
{
/// <summary>
/// Manages state booked.
/// </summary>
[DataContract]
public sealed class StateOccupiedInfo : BaseState, IBaseState, INotAvailableState
{
/// <summary>
/// Prevents an invalid instance to be created.
/// </summary>
private StateOccupiedInfo() : base(InUseStateEnum.Booked)
{
}
/// <summary>
/// Constructs an object holding booked state info.
/// </summary>
/// <param name="p_oFrom">Date time when bike was booked</param>
/// <param name="p_strMailAddress"></param>
/// <param name="p_strCode"></param>
public StateOccupiedInfo(
DateTime p_oFrom,
string p_strMailAddress,
string p_strCode) : base(InUseStateEnum.Booked)
{
From = p_oFrom;
MailAddress = p_strMailAddress;
Code = p_strCode;
}
/// <summary> Constructor for Json serialization. </summary>
/// <param name="Value">Unused value.</param>
/// <param name="From">Date time when bike was booked</param>
/// <param name="MailAddress"></param>
/// <param name="Code"></param>
[JsonConstructor]
private StateOccupiedInfo(
InUseStateEnum Value,
DateTime From,
string MailAddress,
string Code) : this(From, MailAddress, Code)
{
}
/// <summary>
/// Gets the info that state is reserved.
/// Setter exists only for serialization purposes.
/// </summary>
public override InUseStateEnum Value
{
get
{
return InUseStateEnum.Booked;
}
}
/// <summary>
/// Prevents an invalid instance to be created.
/// </summary>
[DataMember]
public DateTime From { get; }
/// <summary>
/// Mail address of user who bookec the bike.
/// </summary>
[DataMember]
public string MailAddress { get; }
/// <summary>
/// Booking code.
/// </summary>
[DataMember]
public string Code { get; }
}
}