File tree 4 files changed +12
-12
lines changed
4 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ public async Task<ActionResult<Product>> Post([FromForm] ProductDtoRequest req)
25
25
try
26
26
{
27
27
using var ms = new MemoryStream ( ) ;
28
- await req . Image . CopyToAsync ( ms ) ;
29
-
28
+ if ( req . Image != null ) await req . Image . CopyToAsync ( ms ) ;
29
+
30
30
var product = new Product
31
31
{
32
32
Name = req . Name ,
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ namespace Catalog.Core.DTO;
4
4
5
5
public class ProductDtoRequest
6
6
{
7
- public string Name { get ; set ; }
8
- public string Description { get ; set ; }
7
+ public string ? Name { get ; set ; }
8
+ public string ? Description { get ; set ; }
9
9
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 ; }
12
12
public int Stock { get ; set ; }
13
13
}
Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ namespace Catalog.Core.DTO;
3
3
public class ProductDtoResponse
4
4
{
5
5
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 ; }
8
8
public decimal Price { get ; set ; }
9
- public string Category { get ; set ; }
9
+ public string ? Category { get ; set ; }
10
10
public int Stock { get ; set ; }
11
11
public DateTime CreatedAt { get ; set ; }
12
12
public DateTime UpdatedAt { get ; set ; }
Original file line number Diff line number Diff line change @@ -2,10 +2,10 @@ namespace Catalog.Core.Entities;
2
2
3
3
public class Product : EntityBase
4
4
{
5
- public string Name { get ; set ; }
6
- public string Description { get ; set ; }
5
+ public string ? Name { get ; set ; }
6
+ public string ? Description { get ; set ; }
7
7
public decimal Price { get ; set ; }
8
- public string Category { get ; set ; }
8
+ public string ? Category { get ; set ; }
9
9
public byte [ ] ? Image { get ; set ; }
10
10
public int Stock { get ; set ; }
11
11
}
You can’t perform that action at this time.
0 commit comments