Skip to content

Commit f30f688

Browse files
minor update - ready for tests
1 parent 53efeb3 commit f30f688

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
**/.vs/**
33
**/bin
44
**/obj
5+
/coverage

CarvedRock.Api/Controllers/ProductController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ namespace CarvedRock.Api.Controllers;
1010
[ApiController]
1111
[Route("[controller]")]
1212
public partial class ProductController(ILogger<ProductController> logger, IProductLogic productLogic,
13-
NewProductValidator validator) : ControllerBase
13+
NewProductValidator validator, IWebHostEnvironment webHostEnv) : ControllerBase
1414
{
1515
[HttpGet]
1616
[AllowAnonymous]
1717
public async Task<IEnumerable<Product>> Get(string category = "all")
1818
{
19+
var env = webHostEnv.EnvironmentName;
1920
return await productLogic.GetProductsForCategoryAsync(category);
2021
}
2122

CarvedRock.Domain/ProductLogic.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Diagnostics;
21
using AutoMapper;
32
using CarvedRock.Core;
43
using CarvedRock.Data;
@@ -13,12 +12,7 @@ public class ProductLogic(ILogger<ProductLogic> logger, ICarvedRockRepository re
1312
public async Task<IEnumerable<Product>> GetProductsForCategoryAsync(string category)
1413
{
1514
logger.LogInformation("Getting products in logic for {category}", category);
16-
17-
Activity.Current?.AddEvent(new ActivityEvent("Getting products from repository"));
18-
var results = await repo.GetProductsAsync(category);
19-
Activity.Current?.AddEvent(new ActivityEvent("Retrieved products from repository"));
20-
21-
return results;
15+
return await repo.GetProductsAsync(category);
2216
}
2317

2418
public async Task<Product?> GetProductByIdAsync(int id)

CarvedRock.Domain/ProductValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public NewProductValidator(ICarvedRockRepository repo)
3939
.WithMessage(p => $"Price for {p.Category} must be between {_priceRanges[p.Category]!.Min:C} and {_priceRanges[p.Category]!.Max:C}");
4040

4141
RuleFor(p => p.ImgUrl)
42-
.Must(url => Uri.IsWellFormedUriString(url, UriKind.Absolute))
42+
.Must(url => Uri.IsWellFormedUriString(url, UriKind.Absolute)).WithMessage("{PropertyName} must be a valid URL.")
4343
.MaximumLength(255).WithMessage("{PropertyName} must not exceed 255 characters.");
4444
}
4545

0 commit comments

Comments
 (0)