Skip to content

Commit 41af68f

Browse files
authored
Merge branch 'main' into DNenchev/48
2 parents af85d97 + f7ac17f commit 41af68f

File tree

11 files changed

+44
-86
lines changed

11 files changed

+44
-86
lines changed

NorthwindCRUD/Controllers/ProductsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public ActionResult<ProductDto> Create(ProductDto model)
268268
}
269269
catch (InvalidOperationException exception)
270270
{
271-
return StatusCode(400, exception.Message);
271+
return StatusCode(400, exception.Message);
272272
}
273273
catch (Exception error)
274274
{
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
using Microsoft.OpenApi.Any;
2-
using Microsoft.OpenApi.Models;
3-
using Swashbuckle.AspNetCore.SwaggerGen;
1+
using Microsoft.OpenApi.Any;
2+
using Microsoft.OpenApi.Models;
3+
using Swashbuckle.AspNetCore.SwaggerGen;
44

5-
namespace NorthwindCRUD.Filters
5+
namespace NorthwindCRUD.Filters
66
{
77
public class EnumSchemaFilter : ISchemaFilter
88
{
99
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
1010
{
1111
if (context.Type.IsEnum)
1212
{
13-
var enumValues = Enum.GetValues(context.Type)
14-
.Cast<object>()
15-
.Select(e => new OpenApiString(e.ToString()))
13+
schema.Type = "string";
14+
schema.Enum = context.Type
15+
.GetEnumNames()
16+
.Select(name => new OpenApiString(name))
1617
.ToList<IOpenApiAny>();
17-
18-
schema.Enum = enumValues;
1918
}
2019
}
2120
}
22-
}
21+
}

NorthwindCRUD/Helpers/Enums.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

NorthwindCRUD/Models/Contracts/IOrder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using NorthwindCRUD.Models.Dtos;
2-
using static NorthwindCRUD.Helpers.Enums;
1+
using NorthwindCRUD.Models.Dtos;
2+
using NorthwindCRUD.Models.Enums;
33

4-
namespace NorthwindCRUD.Models.Contracts
4+
namespace NorthwindCRUD.Models.Contracts
55
{
66
public interface IOrder
77
{

NorthwindCRUD/Models/Dtos/AddressDto.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System.ComponentModel.DataAnnotations;
2-
using NorthwindCRUD.Models.Contracts;
1+
using System.ComponentModel.DataAnnotations;
2+
using NorthwindCRUD.Models.Contracts;
33

4-
namespace NorthwindCRUD.Models.Dtos
4+
namespace NorthwindCRUD.Models.Dtos
55
{
66
public class AddressDto : IAddress
77
{
@@ -24,4 +24,4 @@ public class AddressDto : IAddress
2424
[RegularExpression(@"^\+?[1-9]\d{1,14}$", ErrorMessage = "Phone number is not valid.")]
2525
public string? Phone { get; set; }
2626
}
27-
}
27+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System.ComponentModel.DataAnnotations;
2-
using NorthwindCRUD.Models.Contracts;
1+
using System.ComponentModel.DataAnnotations;
2+
using NorthwindCRUD.Models.Contracts;
33

4-
namespace NorthwindCRUD.Models.Dtos
4+
namespace NorthwindCRUD.Models.Dtos
55
{
66
public class CategoryDetailsDto : CategoryDto, ICategoryDetail
77
{
88
[RegularExpression(@"^(http[s]?://.*\.(?:jpg|jpeg|png|gif))$", ErrorMessage = "Picture URL must start with http/s and end with .jpg, .jpeg, .png, or .gif.")]
99
public string Picture { get; set; }
1010
}
11-
}
11+
}

NorthwindCRUD/Models/Dtos/CategoryDto.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System.ComponentModel.DataAnnotations;
2-
using NorthwindCRUD.Models.Contracts;
1+
using System.ComponentModel.DataAnnotations;
2+
using NorthwindCRUD.Models.Contracts;
33

4-
namespace NorthwindCRUD.Models.Dtos
4+
namespace NorthwindCRUD.Models.Dtos
55
{
66
public class CategoryDto : ICategory
77
{
@@ -14,4 +14,4 @@ public class CategoryDto : ICategory
1414
[StringLength(50, MinimumLength = 3, ErrorMessage = "Name must be between 3 and 50 characters.")]
1515
public string Name { get; set; }
1616
}
17-
}
17+
}

NorthwindCRUD/Models/Dtos/OrderDetailDto.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22

3-
namespace NorthwindCRUD.Models.Dtos
3+
namespace NorthwindCRUD.Models.Dtos
44
{
55
public class OrderDetailDto
66
{
@@ -17,4 +17,4 @@ public class OrderDetailDto
1717

1818
public float Discount { get; set; }
1919
}
20-
}
20+
}

NorthwindCRUD/Models/Dtos/OrderDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
22
using NorthwindCRUD.Models.Contracts;
3-
using static NorthwindCRUD.Helpers.Enums;
3+
using NorthwindCRUD.Models.Enums;
44

55
namespace NorthwindCRUD.Models.Dtos
66
{

NorthwindCRUD/Models/Dtos/ProductDto.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public class ProductDto : IProduct
77
{
88
public int ProductId { get; private set; }
99

10+
public string ProductName { get; set; }
11+
1012
[Range(1, int.MaxValue, ErrorMessage = "SupplierId must be a valid supplier ID.")]
1113
public int? SupplierId { get; set; }
1214

0 commit comments

Comments
 (0)