sharee.bike-App/SharedBusinessLogic/Repository/Response/Stations/StationsAvailableResponse.cs

42 lines
1.5 KiB
C#
Raw Normal View History

2024-04-09 12:53:23 +02:00
using System.Runtime.Serialization;
using Newtonsoft.Json;
using ShareeBike.Repository.Response.Stations.Station;
namespace ShareeBike.Repository.Response.Stations
{
/// <summary>
/// Holds the information about all stations and is used for deserialization of copri answer.
/// </summary>
[DataContract]
public class StationsAvailableResponse : ResponseBase
{
public StationsAvailableResponse()
{
stations = new ComparableDictionary< StationInfo>();
bikes_occupied = new ComparableBikeDictionary<BikeInfoReservedOrBooked> { };
}
/// <summary>
/// Dictionary of bikes.
/// </summary>
[DataMember]
public ComparableDictionary< StationInfo> stations { get; private set; }
/// <summary>
/// Dictionary of bikes reserved (requested) and rented (occupied) by current user if user is logged in and has reserved or rented bikes.
/// </summary>
[DataMember]
public ComparableBikeDictionary<BikeInfoReservedOrBooked> bikes_occupied { get; private set; }
public static bool operator ==(StationsAvailableResponse first, StationsAvailableResponse second)
=> JsonConvert.SerializeObject(first) == JsonConvert.SerializeObject(second);
public static bool operator !=(StationsAvailableResponse first, StationsAvailableResponse second)
=> !(first == second);
public override bool Equals(object obj) => obj is StationsAvailableResponse target && target == this;
public override int GetHashCode() => JsonConvert.SerializeObject(this).GetHashCode();
}
}