public IActionResult CreateNewEmployee([FromBody] EditEmployeeVm editEmployeeVm) { FullEmployeeVm newEmployee = new FullEmployeeVm(); newEmployee.Id = _employees.Count == 0 ? 1 : _employees.Max(e => e.Id) + 1; newEmployee.Update(editEmployeeVm); _employees.Add(newEmployee); return(Json(newEmployee.Id)); }
public IActionResult UpdateEmployee(int id, [FromBody] EditEmployeeVm editEmployeeVm) { FullEmployeeVm employee = _employees.SingleOrDefault(e => e.Id == id); if (employee == null) { return(HttpNotFound()); } employee.Update(editEmployeeVm); return(Json(employee.Id)); }