73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace RoutingWebSite
|
|
{
|
|
// This controller combines routes on the controller with routes on actions in a REST + navigation property
|
|
// style.
|
|
[Route("api/Employee")]
|
|
public class EmployeeController : Controller
|
|
{
|
|
private readonly TestResponseGenerator _generator;
|
|
|
|
public EmployeeController(TestResponseGenerator generator)
|
|
{
|
|
_generator = generator;
|
|
}
|
|
|
|
public IActionResult List()
|
|
{
|
|
return _generator.Generate("/api/Employee");
|
|
}
|
|
|
|
[AcceptVerbs("PUT", "PATCH")]
|
|
public IActionResult UpdateEmployee()
|
|
{
|
|
return _generator.Generate("/api/Employee");
|
|
}
|
|
|
|
[AcceptVerbs("PUT", "PATCH", Route = "Manager")]
|
|
public IActionResult UpdateManager()
|
|
{
|
|
return _generator.Generate("/api/Employee/Manager");
|
|
}
|
|
|
|
[HttpMerge("{id}")]
|
|
public IActionResult MergeEmployee(int id)
|
|
{
|
|
return _generator.Generate("/api/Employee/" + id);
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
public IActionResult Get(int id)
|
|
{
|
|
return _generator.Generate("/api/Employee/" + id);
|
|
}
|
|
|
|
[HttpGet("{id}/Administrator")]
|
|
public IActionResult GetAdministrator(int id)
|
|
{
|
|
return _generator.Generate("/api/Employee/" + id + "/Administrator");
|
|
}
|
|
|
|
[HttpGet("~/Manager/{id}")]
|
|
public IActionResult GetManager(int id)
|
|
{
|
|
return _generator.Generate("/Manager/" + id);
|
|
}
|
|
|
|
[HttpDelete("{id}/Administrator")]
|
|
public IActionResult DeleteAdministrator(int id)
|
|
{
|
|
return _generator.Generate("/api/Employee/" + id + "/Administrator");
|
|
}
|
|
|
|
[Route("{id}/Salary")]
|
|
public IActionResult Salary(int id)
|
|
{
|
|
return _generator.Generate("/api/Employee/" + id + "/Salary");
|
|
}
|
|
}
|
|
} |