|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using System.Threading.Tasks; |
5 | | -using EFDropDown.Shared.DataAccess; |
6 | | -using EFDropDown.Shared.Models; |
7 | | -using Microsoft.AspNetCore.Mvc; |
8 | | - |
9 | | -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 |
10 | | - |
11 | | -namespace EFDropDown.Controllers |
12 | | -{ |
13 | | - |
14 | | - [Route("api/Region")] |
15 | | - public class RegionController : Controller |
16 | | - { |
17 | | - DataAccessLayer db = new DataAccessLayer(); |
18 | | - |
19 | | - [HttpGet] |
20 | | - [Route("GetRegion")] |
21 | | - public IEnumerable<Region> GetRegion() |
22 | | - { |
23 | | - return db.GetAllRegion().AsQueryable(); |
24 | | - } |
25 | | - |
26 | | - [HttpGet] |
27 | | - [Route("GetTerritories")] |
28 | | - public IEnumerable<Territories> GetTerritories() |
29 | | - { |
30 | | - return db.GetAllTerritoriesData().AsQueryable(); |
31 | | - } |
32 | | - |
33 | | - // GET: api/<controller> |
34 | | - [HttpGet] |
35 | | - public IEnumerable<Region> Get() |
36 | | - { |
37 | | - return db.GetAllRegion().AsQueryable(); |
38 | | - } |
39 | | - |
40 | | - //// GET api/<controller>/5 |
41 | | - [HttpGet("{id}")] |
42 | | - public IEnumerable<Territories> Get(int id) |
43 | | - { |
44 | | - return db.GetTerritoriesData(id).AsQueryable(); |
45 | | - } |
46 | | - // GET api/<controller>/5 |
47 | | - |
48 | | - // POST api/<controller> |
49 | | - [HttpPost] |
50 | | - public void Post([FromBody]string value) |
51 | | - { |
52 | | - } |
53 | | - |
54 | | - // PUT api/<controller>/5 |
55 | | - [HttpPut("{id}")] |
56 | | - public void Put(int id, [FromBody]string value) |
57 | | - { |
58 | | - } |
59 | | - |
60 | | - // DELETE api/<controller>/5 |
61 | | - [HttpDelete("{id}")] |
62 | | - public void Delete(int id) |
63 | | - { |
64 | | - } |
65 | | - } |
66 | | -} |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Threading.Tasks; |
| 5 | +using DropDownListWithEF.Shared.DataAccess; |
| 6 | +using DropDownListWithEF.Shared.Models; |
| 7 | +using Microsoft.AspNetCore.Mvc; |
| 8 | + |
| 9 | +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 |
| 10 | + |
| 11 | +namespace DropDownListWithEF.Controllers |
| 12 | +{ |
| 13 | + |
| 14 | + [Route("api/Region")] |
| 15 | + public class RegionController : Controller |
| 16 | + { |
| 17 | + DataAccessLayer db = new DataAccessLayer(); |
| 18 | + |
| 19 | + [HttpGet] |
| 20 | + [Route("GetRegion")] |
| 21 | + public IEnumerable<Region> GetRegion() |
| 22 | + { |
| 23 | + return db.GetAllRegion().AsQueryable(); |
| 24 | + } |
| 25 | + |
| 26 | + [HttpGet] |
| 27 | + [Route("GetTerritories")] |
| 28 | + public IEnumerable<Territories> GetTerritories() |
| 29 | + { |
| 30 | + return db.GetAllTerritoriesData().AsQueryable(); |
| 31 | + } |
| 32 | + |
| 33 | + // GET: api/<controller> |
| 34 | + [HttpGet] |
| 35 | + public IEnumerable<Region> Get() |
| 36 | + { |
| 37 | + return db.GetAllRegion().AsQueryable(); |
| 38 | + } |
| 39 | + |
| 40 | + //// GET api/<controller>/5 |
| 41 | + [HttpGet("{id}")] |
| 42 | + public IEnumerable<Territories> Get(int id) |
| 43 | + { |
| 44 | + return db.GetTerritoriesData(id).AsQueryable(); |
| 45 | + } |
| 46 | + // GET api/<controller>/5 |
| 47 | + |
| 48 | + // POST api/<controller> |
| 49 | + [HttpPost] |
| 50 | + public void Post([FromBody]string value) |
| 51 | + { |
| 52 | + } |
| 53 | + |
| 54 | + // PUT api/<controller>/5 |
| 55 | + [HttpPut("{id}")] |
| 56 | + public void Put(int id, [FromBody]string value) |
| 57 | + { |
| 58 | + } |
| 59 | + |
| 60 | + // DELETE api/<controller>/5 |
| 61 | + [HttpDelete("{id}")] |
| 62 | + public void Delete(int id) |
| 63 | + { |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments