fix: invalid arrival address details in TicketGroupDto; add isPurchased field

Before this arrival address info in TicketGroupDto was being populated by first ticket arrival address info
This commit is contained in:
cuqmbr 2023-05-25 11:49:37 +03:00
parent 7cf3f34f28
commit 5fecec2d3e
4 changed files with 10 additions and 6 deletions

View File

@ -9,6 +9,7 @@ public class TicketGroup
public DateTime PurchaseDateTimeUtc { get; set; } = DateTime.MinValue;
public bool IsReturned { get; set; } = false;
public string UserId { get; set; } = null!;
public User User { get; set; } = null!;
@ -88,5 +89,6 @@ public class TicketGroup
.First(ra => ra.AddressId == Tickets.Last().LastRouteAddressId)
.Address;
}
public bool IsPurchased() => PurchaseDateTimeUtc != DateTime.MinValue;
}

View File

@ -192,6 +192,7 @@ public class TicketGroupManagementService : ITicketGroupManagementService
{
Id = ticketGroup.Id,
IsReturned = ticketGroup.IsReturned,
IsPurchased = ticketGroup.PurchaseDateTimeUtc != DateTime.MinValue,
PurchaseDateTime = ticketGroup.PurchaseDateTimeUtc,
DepartureAddressName = ticketGroup.Tickets.First().GetDepartureAddress().Name,
DepartureCityName = ticketGroup.Tickets.First().GetDepartureAddress().City.Name,
@ -199,11 +200,11 @@ public class TicketGroupManagementService : ITicketGroupManagementService
DepartureCountryName = ticketGroup.Tickets.First().GetDepartureAddress().City.State.Country.Name,
DepartureFullName = ticketGroup.Tickets.First().GetDepartureAddress().GetFullName(),
DepartureDateTime = ticketGroup.Tickets.First().GetDepartureTime(),
ArrivalAddressName = ticketGroup.Tickets.First().GetArrivalAddress().Name,
ArrivalCityName = ticketGroup.Tickets.First().GetArrivalAddress().City.Name,
ArrivalStateName = ticketGroup.Tickets.First().GetArrivalAddress().City.State.Name,
ArrivalCountryName = ticketGroup.Tickets.First().GetArrivalAddress().City.State.Country.Name,
ArrivalFullName = ticketGroup.Tickets.First().GetArrivalAddress().GetFullName(),
ArrivalAddressName = ticketGroup.Tickets.Last().GetArrivalAddress().Name,
ArrivalCityName = ticketGroup.Tickets.Last().GetArrivalAddress().City.Name,
ArrivalStateName = ticketGroup.Tickets.Last().GetArrivalAddress().City.State.Name,
ArrivalCountryName = ticketGroup.Tickets.Last().GetArrivalAddress().City.State.Country.Name,
ArrivalFullName = ticketGroup.Tickets.Last().GetArrivalAddress().GetFullName(),
ArrivalDateTime = ticketGroup.Tickets.Last().GetArrivalTime(),
Cost = ticketGroup.GetCost(),
Tickets = inGroupTicketDtos

View File

@ -9,6 +9,7 @@ public class TicketGroupDto
[DataType(DataType.DateTime)]
public DateTime PurchaseDateTime { get; set; }
public bool IsReturned { get; set; } = false;
public bool IsPurchased { get; set; }
public string DepartureAddressName { get; set; } = null!;
public string DepartureCityName { get; set; } = null!;

View File

@ -3,7 +3,7 @@ namespace SharedModels.QueryParameters.Objects;
public class TicketGroupParameters : ParametersBase
{
public const string DefaultFields =
"id,userId,purchaseDateTime,isReturned,departureAddressName,departureCityName,departureStateName,departureCountryName," +
"id,userId,purchaseDateTime,isReturned,isPurchased,departureAddressName,departureCityName,departureStateName,departureCountryName," +
"departureFullName,departureDateTime,arrivalAddressName,arrivalCityName,arrivalStateName,arrivalCountryName,arrivalFullName," +
"arrivalDateTime,cost,tickets";