sharee.bike-App/TINKLib/Model/Bikes/BikeInfoNS/CopriLock/BikeInfoMutable.cs
2023-01-18 14:22:51 +01:00

49 lines
1.2 KiB
C#

using System;
namespace TINK.Model.Bikes.BikeInfoNS.CopriLock
{
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
{
/// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike, string stationName) : base(
bike != null
? bike.Bike
: throw new ArgumentNullException(nameof(bike)),
bike.Drive,
bike.DataSource,
bike.IsDemo,
bike.Group,
bike.StationId,
stationName,
bike.OperatorUri,
bike.TariffDescription,
() => DateTime.Now,
bike.State)
{
LockInfo = new LockInfoMutable(bike.LockInfo.State);
BookingFinishedModel = new BookingFinishedModel
{
Co2Saving = bike.Co2Saving,
MiniSurvey = new MiniSurvey.MiniSurveyModel()
};
if ((bike?.MiniSurvey?.Questions) == null
|| bike.MiniSurvey.Questions.Count <= 0)
{
// No querries to add.
return;
}
// Add a dummy querry. Querries are not yet read from COPRI but compiled into the app.
BookingFinishedModel.MiniSurvey.Questions.Add("q1", new MiniSurvey.QuestionModel());
}
public LockInfoMutable LockInfo { get; }
ILockInfoMutable IBikeInfoMutable.LockInfo => LockInfo;
public IBookingFinishedModel BookingFinishedModel { get; }
}
}