How to represent create new employee record by web API ?
i work on project asp.net core 2.1
i create mvc controller employee controller and inside it i make create action result for create new employee view with
get type and show last record exist on database plus one as below :
- public IActionResult Create()
- {
- var model = new Employee();
- if (id == null)
- {
- model.EmployeeId = _repository.GetAll().Max(Employee => Employee.EmployeeId) + 1;
- }
- return View(model);
- }
so that
How to convert function action result create to web API ?
so that i create new web API controller :
- [Produces("application/json")]
- [Route("api/Employee")]
- public class EmployeeController : Controller
- {
- //how to write code for create by using web api
- }
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Laxmidhar SahooPosted Feb 16, 2019, 3:30 AM