public ActionResult AddAnEmployee([FromBody] NewEmployee employee, [FromServices] IGeneratorEmpolyeeIds idGenerator) { // var idGenerator = new EmpolyeeIdGenerator(); var id = idGenerator.GetNewEmployeeId(); return(Ok($"Hiring {employee.Name} starting at {employee.StartingSalary.ToString("c")} with an id of {id.ToString()}")); }
public ActionResult AddEmployee([FromBody] NewEmployee employee, [FromServices] IGenerateEmployeeIds idGenerator) { //var idGenerator = new EmployeeIdGenerator(); employee.Id = idGenerator.GetNewEmployeeId(); return(Ok($"Hiring {employee.Name} starting at {employee.StartingSalary.ToString("c")} ID:{employee.Id}")); }
public ActionResult AddAnEmployee([FromBody] NewEmployee employee, [FromServices] IGenerateEmployeeIds idGenerator) { // new keyword means tightly coupled to a service //var idGenerator = new EmployeeIdGenerator(); // instead, add IGenerateEmployeeIds to Startup.cs in Configure Services var id = idGenerator.GetNewEmployeeId(); return(Ok($"Hiring {employee.Name} starting at {employee.StartingSalary.ToString("c")} with id of {id.ToString()}")); }