New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure end date is after start date in Crowdfund app #4084
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,7 @@ public async Task<IActionResult> ContributeToCrowdfund(string appId, ContributeT | |
if (!string.IsNullOrEmpty(request.ChoiceKey)) | ||
{ | ||
var choices = _appService.GetPOSItems(settings.PerksTemplate, settings.TargetCurrency); | ||
choice = choices.FirstOrDefault(c => c.Id == request.ChoiceKey); | ||
choice = choices?.FirstOrDefault(c => c.Id == request.ChoiceKey); | ||
if (choice == null) | ||
return NotFound("Incorrect option provided"); | ||
title = choice.Title; | ||
|
@@ -287,12 +287,17 @@ public async Task<IActionResult> UpdateCrowdfund(string appId, UpdateCrowdfundVi | |
|
||
if (Enum.Parse<CrowdfundResetEvery>(vm.ResetEvery) != CrowdfundResetEvery.Never && !vm.StartDate.HasValue) | ||
{ | ||
ModelState.AddModelError(nameof(vm.StartDate), "A start date is needed when the goal resets every X amount of time."); | ||
ModelState.AddModelError(nameof(vm.StartDate), "A start date is needed when the goal resets every X amount of time"); | ||
} | ||
|
||
if (Enum.Parse<CrowdfundResetEvery>(vm.ResetEvery) != CrowdfundResetEvery.Never && vm.ResetEveryAmount <= 0) | ||
{ | ||
ModelState.AddModelError(nameof(vm.ResetEveryAmount), "You must reset the goal at a minimum of 1 "); | ||
ModelState.AddModelError(nameof(vm.ResetEveryAmount), "You must reset the goal at a minimum of 1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was an extra trailing space here which I removed. |
||
} | ||
|
||
if (vm.StartDate != null && vm.EndDate != null && DateTime.Compare((DateTime)vm.StartDate, (DateTime)vm.EndDate) > 0) | ||
{ | ||
ModelState.AddModelError(nameof(vm.EndDate), "End date cannot be before start date"); | ||
} | ||
|
||
if (vm.DisplayPerksRanking) | ||
|
@@ -374,7 +379,13 @@ private async Task<string> GetStoreDefaultCurrentIfEmpty(string storeId, string | |
{ | ||
if (string.IsNullOrWhiteSpace(currency)) | ||
{ | ||
currency = (await _storeRepository.FindStore(storeId)).GetStoreBlob().DefaultCurrency; | ||
var store = await _storeRepository.FindStore(storeId); | ||
if (store == null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
throw new Exception($"Could not find store with id {storeId}"); | ||
} | ||
|
||
currency = store.GetStoreBlob().DefaultCurrency; | ||
} | ||
return currency.Trim().ToUpperInvariant(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,6 @@ | |
<vc:icon symbol="close"/> | ||
</button> | ||
</div> | ||
<span asp-validation-for="StartDate" class="text-danger"></span> | ||
</div> | ||
<div class="form-group mb-0 w-250px"> | ||
<label asp-for="EndDate" class="form-label"></label> | ||
|
@@ -121,8 +120,9 @@ | |
<vc:icon symbol="close"/> | ||
</button> | ||
</div> | ||
<span asp-validation-for="EndDate" class="text-danger"></span> | ||
</div> | ||
<span asp-validation-for="StartDate" class="text-danger"></span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Placed these below both of the elements so the layout doesn't get messed up if there is an error. |
||
<span asp-validation-for="EndDate" class="text-danger"></span> | ||
</div> | ||
|
||
<div class="form-group mt-4" id="ResetRow" hidden="@(Model.StartDate == null)"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed a period character at the end since other errors don't have it.