sharee.bike-App/TINKLib/Model/State/StateOccupiedInfo.cs

81 lines
1.8 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
2021-05-13 20:03:07 +02:00
using System.Runtime.Serialization;
2022-08-30 15:42:25 +02:00
using Newtonsoft.Json;
2021-05-13 20:03:07 +02:00
namespace TINK.Model.State
{
2022-09-06 16:08:19 +02:00
/// <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)
{
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <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;
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <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)
{
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Gets the info that state is reserved.
/// Setter exists only for serialization purposes.
/// </summary>
public override InUseStateEnum Value
{
get
{
return InUseStateEnum.Booked;
}
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Prevents an invalid instance to be created.
/// </summary>
[DataMember]
public DateTime From { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Mail address of user who bookec the bike.
/// </summary>
[DataMember]
public string MailAddress { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary>
/// Booking code.
/// </summary>
[DataMember]
public string Code { get; }
}
2021-05-13 20:03:07 +02:00
}