fix: Handle null response metadata and models in GetDiscountProductsQueryHandler
Build and Deploy / build (push) Successful in 2m2s
Build and Deploy / build (push) Successful in 2m2s
This commit is contained in:
+5
-5
@@ -41,7 +41,7 @@ public class GetDiscountProductsQueryHandler : IRequestHandler<GetDiscountProduc
|
|||||||
|
|
||||||
return new GetDiscountProductsResponseDto
|
return new GetDiscountProductsResponseDto
|
||||||
{
|
{
|
||||||
MetaData = new MetaData
|
MetaData = response.MetaData != null ? new MetaData
|
||||||
{
|
{
|
||||||
CurrentPage = response.MetaData.CurrentPage,
|
CurrentPage = response.MetaData.CurrentPage,
|
||||||
TotalPage = response.MetaData.TotalPage,
|
TotalPage = response.MetaData.TotalPage,
|
||||||
@@ -49,8 +49,8 @@ public class GetDiscountProductsQueryHandler : IRequestHandler<GetDiscountProduc
|
|||||||
TotalCount = response.MetaData.TotalCount,
|
TotalCount = response.MetaData.TotalCount,
|
||||||
HasPrevious = response.MetaData.HasPrevious,
|
HasPrevious = response.MetaData.HasPrevious,
|
||||||
HasNext = response.MetaData.HasNext
|
HasNext = response.MetaData.HasNext
|
||||||
},
|
} : new MetaData(),
|
||||||
Products = response.Models.Select(p => new DiscountProductDto
|
Products = response.Models?.Select(p => new DiscountProductDto
|
||||||
{
|
{
|
||||||
Id = p.Id,
|
Id = p.Id,
|
||||||
Title = p.Title,
|
Title = p.Title,
|
||||||
@@ -62,8 +62,8 @@ public class GetDiscountProductsQueryHandler : IRequestHandler<GetDiscountProduc
|
|||||||
RemainingCount = p.RemainingCount,
|
RemainingCount = p.RemainingCount,
|
||||||
ViewCount = p.ViewCount,
|
ViewCount = p.ViewCount,
|
||||||
IsActive = p.IsActive,
|
IsActive = p.IsActive,
|
||||||
Created = p.Created.ToDateTime()
|
Created = p.Created?.ToDateTime() ?? DateTime.MinValue
|
||||||
}).ToList()
|
}).ToList() ?? new List<DiscountProductDto>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user