public async Task <ActionResult <AllDiscountsDTO> > Discounts([FromBody] GuidDTO guidDTO) { if (guidDTO.Id == Guid.Empty) { return(BadRequest("Invalid store ID")); } ICollection <DiscountData>?leafDiscounts = await MarketRulesService.GetAllDiscounts(guidDTO.Id); if (leafDiscounts == null) { return(InternalServerError()); } ICollection <DiscountsRelation>?discountsRelations = await MarketRulesService.GetAllDiscountsRelations(guidDTO.Id); if (discountsRelations == null) { return(InternalServerError()); } return(Ok(new AllDiscountsDTO { LeafDiscounts = leafDiscounts.Select(DiscountDataDTO.FromDiscountData), RelationDiscounts = discountsRelations.Select(DiscountDataCompundDTO.FromDiscountRelation), })); }
public async Task <ActionResult <IEnumerable <PolicyDataDTO> > > Policies([FromBody] GuidDTO guidDTO) { if (guidDTO.Id == Guid.Empty) { return(BadRequest("Invalid store ID")); } List <PolicyData>?policies = await MarketRulesService.GetAllPolicies(guidDTO.Id); if (policies == null) { return(InternalServerError()); } return(Ok(policies.Select(PolicyDataDTO.FromPolicyData))); }