2025-11-16 11:25:27 +00:00
|
|
|
import 'package:mnemo_cards_backend/extensions.dart';
|
|
|
|
|
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
|
|
|
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
|
|
|
|
|
|
|
|
|
extension DiscountCampaignModelExt on DiscountCampaignModel {
|
|
|
|
|
Future<DiscountCampaignDto> toDto() async {
|
|
|
|
|
return DiscountCampaignDto(
|
|
|
|
|
id: id,
|
|
|
|
|
start: this.start,
|
|
|
|
|
finish: this.finish,
|
|
|
|
|
status: status.toDto(),
|
|
|
|
|
name: name,
|
|
|
|
|
tags: this.tags,
|
|
|
|
|
discounts: discounts.map((d) => d.toDto()).toList(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension DiscountExt on DiscountModel {
|
|
|
|
|
DiscountDto toDto() => DiscountDto(
|
|
|
|
|
discountPercent: discountPercent,
|
|
|
|
|
products: products.map((p) => p.toDto()).toList(),
|
|
|
|
|
id: id?.toString(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension DiscountModelExt on DiscountDto {
|
|
|
|
|
DiscountModel toModel() => DiscountModel(
|
|
|
|
|
discountPercent: discountPercent,
|
|
|
|
|
products: products.map((p) => p.toModel()).toBaseList(),
|
2025-12-13 20:55:50 +00:00
|
|
|
id: id,
|
2025-11-16 11:25:27 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension DiscountCampaignModelStatusExt on DiscountCampaignModelStatus {
|
|
|
|
|
DiscountCampaignStatus toDto() {
|
|
|
|
|
return switch (this) {
|
|
|
|
|
DiscountCampaignModelStatus.created => DiscountCampaignStatus.created,
|
|
|
|
|
DiscountCampaignModelStatus.active => DiscountCampaignStatus.active,
|
|
|
|
|
DiscountCampaignModelStatus.expired => DiscountCampaignStatus.expired,
|
|
|
|
|
DiscountCampaignModelStatus.disabled => DiscountCampaignStatus.disabled,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension DiscountCampaignStatusExt on DiscountCampaignStatus {
|
|
|
|
|
DiscountCampaignModelStatus toModel() {
|
|
|
|
|
return switch (this) {
|
|
|
|
|
DiscountCampaignStatus.created => DiscountCampaignModelStatus.created,
|
|
|
|
|
DiscountCampaignStatus.active => DiscountCampaignModelStatus.active,
|
|
|
|
|
DiscountCampaignStatus.disabled => DiscountCampaignModelStatus.disabled,
|
|
|
|
|
DiscountCampaignStatus.expired => DiscountCampaignModelStatus.expired,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|