Skip to content

Commit 4da56f8

Browse files
minor final updates
1 parent f30f688 commit 4da56f8

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

CarvedRock.Domain/ProductValidator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public NewProductValidator(ICarvedRockRepository repo)
4545

4646
private bool PriceIsValid(NewProductModel ctx, double priceToValidate)
4747
{
48+
if (!_priceRanges.ContainsKey(ctx.Category)) return true; // no category defined
49+
4850
var range = _priceRanges[ctx.Category];
4951
return priceToValidate >= range.Min && priceToValidate <= range.Max;
5052
}

CarvedRock.WebApp/Pages/Cart.cshtml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
using Microsoft.AspNetCore.Authorization;
12
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
34
using System.Text.Json;
45

56
namespace CarvedRock.WebApp.Pages;
67

78
public record CartItem(int Id, int Quantity, string Name, string Category, double Price, double Total);
9+
810
[ValidateAntiForgeryToken]
911
public class CartModel(IProductService productService) : PageModel
1012
{

CarvedRock.WebApp/Pages/Listing.cshtml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,8 @@
3030
setCartCount(); // defined in layout page
3131
}
3232
function setCookie(cname, cvalue) {
33-
document.cookie = cname + "=" + cvalue + ";path=/;Secure;SameSite=Strict";
34-
}
35-
36-
// function getCookie(cname) {
37-
// let name = cname + "=";
38-
// let decodedCookie = decodeURIComponent(document.cookie);
39-
// let ca = decodedCookie.split(';');
40-
// for (let i = 0; i < ca.length; i++) {
41-
// let c = ca[i];
42-
// while (c.charAt(0) == ' ') {
43-
// c = c.substring(1);
44-
// }
45-
// if (c.indexOf(name) == 0) {
46-
// return c.substring(name.length, c.length);
47-
// }
48-
// }
49-
// return "";
50-
// }
33+
document.cookie = cname + "=" + cvalue + ";path=/;SameSite=Lax";
34+
}
5135
</script>
5236

5337
<h1>@Model.CategoryName</h1>

0 commit comments

Comments
 (0)