Skip to content

Commit 848611c

Browse files
committed
fix(put): update employee endpoint to include notfound
1 parent a110125 commit 848611c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

NorthwindCRUD/Controllers/EmployeeController.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using AutoMapper;
44
using Microsoft.AspNetCore.Authorization;
55
using Microsoft.AspNetCore.Mvc;
6+
using NorthwindCRUD.Models.Contracts;
67
using NorthwindCRUD.Models.DbModels;
78
using NorthwindCRUD.Models.InputModels;
89
using NorthwindCRUD.Services;
@@ -92,7 +93,13 @@ public ActionResult<EmployeeInputModel> Update(EmployeeInputModel model)
9293
{
9394
var mappedModel = this.mapper.Map<EmployeeInputModel, EmployeeDb>(model);
9495
var employee = this.employeeService.Update(mappedModel);
95-
return Ok(this.mapper.Map<EmployeeDb, EmployeeInputModel>(employee));
96+
97+
if (employee != null)
98+
{
99+
return Ok(this.mapper.Map<EmployeeDb, EmployeeInputModel>(employee));
100+
}
101+
102+
return NotFound();
96103
}
97104

98105
return BadRequest(ModelState);

0 commit comments

Comments
 (0)