Skip to content

Commit ab44201

Browse files
authored
Merge pull request #3 from babisque/feature/products-services-improvements
Code improvements to become nullable strings
2 parents 8f2803d + 4d2c9bb commit ab44201

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Catalog/Catalog.API/Controllers/ProductController.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public async Task<ActionResult<Product>> Post([FromForm] ProductDtoRequest req)
2525
try
2626
{
2727
using var ms = new MemoryStream();
28-
await req.Image.CopyToAsync(ms);
29-
28+
if (req.Image != null) await req.Image.CopyToAsync(ms);
29+
3030
var product = new Product
3131
{
3232
Name = req.Name,

Catalog/Catalog.Core/DTO/ProductDtoRequest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace Catalog.Core.DTO;
44

55
public class ProductDtoRequest
66
{
7-
public string Name { get; set; }
8-
public string Description { get; set; }
7+
public string? Name { get; set; }
8+
public string? Description { get; set; }
99
public decimal Price { get; set; }
10-
public string Category { get; set; }
11-
public IFormFile Image { get; set; }
10+
public string? Category { get; set; }
11+
public IFormFile? Image { get; set; }
1212
public int Stock { get; set; }
1313
}

Catalog/Catalog.Core/DTO/ProductDtoResponse.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ namespace Catalog.Core.DTO;
33
public class ProductDtoResponse
44
{
55
public int Id { get; set; }
6-
public string Name { get; set; }
7-
public string Description { get; set; }
6+
public string? Name { get; set; }
7+
public string? Description { get; set; }
88
public decimal Price { get; set; }
9-
public string Category { get; set; }
9+
public string? Category { get; set; }
1010
public int Stock { get; set; }
1111
public DateTime CreatedAt { get; set; }
1212
public DateTime UpdatedAt { get; set; }

Catalog/Catalog.Core/Entities/Product.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ namespace Catalog.Core.Entities;
22

33
public class Product : EntityBase
44
{
5-
public string Name { get; set; }
6-
public string Description { get; set; }
5+
public string? Name { get; set; }
6+
public string? Description { get; set; }
77
public decimal Price { get; set; }
8-
public string Category { get; set; }
8+
public string? Category { get; set; }
99
public byte[]? Image { get; set; }
1010
public int Stock { get; set; }
1111
}

0 commit comments

Comments
 (0)