public ActionResult Hire([FromBody] EmployeeCreateRequest employeeTohire)
        {
            // 1. Validate
            //  Throw error if bad
            // 2. Add it to a database... or whatever
            var response = new EmployeeResponse
            {
                Id             = new Random().Next(10, 100000),
                Name           = employeeTohire.Name,
                Department     = employeeTohire.Department,
                StartingSalary = employeeTohire.StartingSalary,
                HireDate       = DateTime.Now
            };

            // 3. return a 201 Created status code
            // 4. Include in teh response a link to the brand new baby resource (location: http://blah/employees/{id}
            // 5. (usually) just send them a copy of what they would get if they went to that location
            return(CreatedAtRoute("employees#getanemployee", new { employeeId = response.Id }, response));
        }
 public ActionResult Hire([FromBody] EmployeeCreateRequest employeeToHire)
 {
     // 1. Validate it. (we'll do this tomorrow)
     //   - if not valid, send a 400 back telling them they are a bonehead.
     // 2. Add it to the database, whatever.
     var employeeResponse = new EmployeeResponse
     {
         Id = new Random().Next(10, 10000),
         Name = employeeToHire.Name,
         Department = employeeToHire.Department,
         HireDate = DateTime.Now,
         StartingSalary = employeeToHire.StartingSalary
     };
     // 3. Return a 201 Created status code.
     // 4. Inlclude in the response a link to the brand new baby resource (Location: http://localhost:1337/employees/58)
     // 5. (usually) just send them a copy of what they would get if they went to that location.
     return CreatedAtRoute("employees#getanemployee",
         new { employeeId = employeeResponse.Id },
         employeeResponse);
 }
        public ActionResult Hire([FromBody] EmployeeCreateRequest employeeToHire)
        {
            // 1. Validate
            // - if not valid, send a 400 back telling them they are boneheaded
            // 2. Add it to the database, whatever,
            var employeeResponse = new EmployeeResponse
            {
                Id             = new Random().Next(10, 15000),
                Name           = employeeToHire.Name,
                Department     = employeeToHire.Department,
                HireDate       = Clock.GetCurrent(),
                StartingSalary = employeeToHire.StartingSalary + 50000
            };

            // 3. Return a 201 Created status code.
            // 4. Include in the response a link to the brand new baby resource (location: http://localhost:1337
            // 5. (usually) just send them a copy of what they would get if they went to that location.
            return(CreatedAtRoute("employees#getanemployee",
                                  new { employeeId = employeeResponse.Id },
                                  employeeResponse));
        }
Exemple #4
0
 public ActionResult HireEmployee([FromBody] EmployeeCreateRequest employeeToHire,
                                  [FromHeader(Name = "Content-Type")] string ellis)
 {
     return(Ok($"Hiring {employeeToHire.LastName} as a {employeeToHire.Department} \n {ellis}"));
 }
 public ActionResult HireEmployee([FromBody] EmployeeCreateRequest employeeToHire)
 {
     return(Ok($"Hiring {employeeToHire.LastName} as a {employeeToHire.Department}"));
 }