sharee.bike-App/SharedBusinessLogic/Repository/Response/BikesAvailableResponse.cs
2024-04-09 12:53:23 +02:00

37 lines
1.3 KiB
C#

using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace ShareeBike.Repository.Response
{
/// <summary>
/// Holds the information about all bikes and is used for deserialization of copri answer.
/// </summary>
[DataContract]
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class BikesAvailableResponse : ResponseBase
{
public BikesAvailableResponse()
{
bikes = new ComparableBikeDictionary<BikeInfoAvailable> ();
bikes_occupied = new ComparableBikeDictionary<BikeInfoReservedOrBooked> ();
}
/// <summary> Dictionary of bikes available.</summary>
[DataMember]
public ComparableBikeDictionary<BikeInfoAvailable> bikes { get; private set; }
/// <summary> Dictionary of bikes reserved or booked.</summary>
[DataMember]
public ComparableBikeDictionary<BikeInfoReservedOrBooked> bikes_occupied { get; private set; }
public static bool operator== (BikesAvailableResponse first, BikesAvailableResponse second)
=> JsonConvert.SerializeObject(first) == JsonConvert.SerializeObject(second);
public static bool operator !=(BikesAvailableResponse first, BikesAvailableResponse second)
=> !(first == second);
public override bool Equals(object obj) => obj is BikesAvailableResponse target && target == this;
public override int GetHashCode() => JsonConvert.SerializeObject(this).GetHashCode();
}
}