Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Doppler.HtmlEditorApi/ApiModels/PromoCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public record PromoCode(
decimal minPrice,
int maxUses,
string categories,
string prefix
string prefix,
string store
) : IValidatableObject
{
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { yield break; }
Expand Down
6 changes: 4 additions & 2 deletions Doppler.HtmlEditorApi/Controllers/CampaignsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ public async Task<Results<NotFound<ProblemDetails>, CreatedAtRoute<ResourceCreat
MaxUses: promoCode.maxUses,
Categories: promoCode.categories,
CampaignId: campaignId,
Prefix: promoCode.prefix
Prefix: promoCode.prefix,
Store: promoCode.store
);

var result = await _promoCodeRepository.CreatePromoCode(promoCodeModel);
Expand All @@ -230,7 +231,8 @@ public async Task<IActionResult> UpdatePromoCode(string accountName, int campaig
MaxUses: promoCode.maxUses,
Categories: promoCode.categories,
CampaignId: campaignId,
Prefix: promoCode.prefix
Prefix: promoCode.prefix,
Store: promoCode.store
);

var updateResult = await _promoCodeRepository.UpdatePromoCode(promoCodeModel);
Expand Down
3 changes: 2 additions & 1 deletion Doppler.HtmlEditorApi/Domain/PromoCodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public record PromoCodeModel(
int MaxUses,
string Categories,
int CampaignId,
string Prefix
string Prefix,
string Store
);
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public async Task<int> CreatePromoCode(PromoCodeModel promoCodeModel)
MaxUses: promoCodeModel.MaxUses,
Categories: promoCodeModel.Categories,
IdCampaign: promoCodeModel.CampaignId,
Prefix: promoCodeModel.Prefix
Prefix: promoCodeModel.Prefix,
ThirdPartyApp: promoCodeModel.Store
);

var result = await _dbContext.ExecuteAsync(insertPromoCodeDbQuery);
Expand All @@ -48,7 +49,8 @@ public async Task<bool> UpdatePromoCode(PromoCodeModel promoCodeModel)
ExpireDays: promoCodeModel.ExpireDays,
MaxUses: promoCodeModel.MaxUses,
Categories: promoCodeModel.Categories,
Prefix: promoCodeModel.Prefix
Prefix: promoCodeModel.Prefix,
ThirdPartyApp: promoCodeModel.Store
);

var result = await _dbContext.ExecuteAsync(updatePromoCodeDbQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ public record InsertPromoCodeDbQuery(
int MaxUses,
string? Categories,
int IdCampaign,
string Prefix
string Prefix,
string ThirdPartyApp
) : ISingleItemDbQuery<InsertPromoCodeDbQuery.Result>
{
public string GenerateSqlQuery() => @"
DECLARE @IdThirdPartyApp INT;
SELECT @IdThirdPartyApp = IdThirdPartyApp FROM ThirdPartyApp WHERE Name = @ThirdPartyApp;

INSERT INTO DynamicContentPromoCode (
Type,
Value,
Expand All @@ -28,7 +32,8 @@ INSERT INTO DynamicContentPromoCode (
MaxUses,
Categories,
IdCampaign,
Prefix
Prefix,
IdThirdPartyApp
) VALUES (
@Type,
@Value,
Expand All @@ -40,7 +45,8 @@ INSERT INTO DynamicContentPromoCode (
@MaxUses,
@Categories,
@IdCampaign,
@Prefix
@Prefix,
ISNULL(@IdThirdPartyApp, 3)
)

SELECT @@Identity AS IdDynamicContentPromoCode";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ public record UpdatePromoCodeDbQuery(
int ExpireDays,
int MaxUses,
string? Categories,
string Prefix
string Prefix,
string ThirdPartyApp
) : IExecutableDbQuery
{
public string GenerateSqlQuery() => @"
DECLARE @IdThirdPartyApp INT;
SELECT @IdThirdPartyApp = IdThirdPartyApp FROM ThirdPartyApp WHERE Name = @ThirdPartyApp;

UPDATE DynamicContentPromoCode
SET Type = @Type,
Value = @Value,
Expand All @@ -28,6 +32,7 @@ UPDATE DynamicContentPromoCode
ExpireDays = @ExpireDays,
MaxUses = @MaxUses,
Categories = @Categories,
Prefix = @Prefix
Prefix = @Prefix,
IdThirdPartyApp = ISNULL(@IdThirdPartyApp, IdThirdPartyApp)
WHERE IdDynamicContentPromoCode = @Id AND IdCampaign = @IdCampaign";
}
4 changes: 4 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"FIRSTNAME",
"LASTNAME"
]
},
{
"filename": "**/Repositories.DopplerDb/Queries/*.cs",
"ignoreWords": ["ISNULL"]
}
]
}