forked from ExtCore/ExtCore-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemController.cs
More file actions
44 lines (41 loc) · 1.05 KB
/
ItemController.cs
File metadata and controls
44 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using Microsoft.AspNetCore.Mvc;
using DomainModel.Infrastracture.Services;
using DomainModel.Models;
namespace DomainModel.Controllers
{
[Route("api/domainmodel/[controller]")]
public class ItemsController : Controller
{
private IService<Item> _itemService { get; set; }
public ItemsController(IService<Item> itemService)
{
_itemService = itemService;
}
[HttpGet]
public IActionResult Get()
{
return Ok(_itemService.All());
}
[HttpGet("{id}")]
public IActionResult Get(long id)
{
return Ok(_itemService.Find(id));
}
[HttpPost]
public void Post([FromBody]Item value)
{
_itemService.Add(value);
}
[HttpPut("{id}")]
public void Put(long id, [FromBody]Item value)
{
_itemService.Update(id, value);
}
[HttpDelete("{id}")]
public void Delete(long id)
{
_itemService.Delete(id);
}
}
}