Commit 7fd789ffdba5d92b86db184d6fc660e92305b537
1 parent
e8a101e9
Cors
Showing
2 changed files
with
11 additions
and
38 deletions
Show diff stats
src/Maps/Controllers/BusStopController.cs
@@ -85,43 +85,15 @@ namespace Maps.Controllers | @@ -85,43 +85,15 @@ namespace Maps.Controllers | ||
85 | } | 85 | } |
86 | 86 | ||
87 | // GET: BusStop/Create | 87 | // GET: BusStop/Create |
88 | - [HttpGet] | 88 | + [HttpPost] |
89 | public async Task<IActionResult> Create(string data) | 89 | public async Task<IActionResult> Create(string data) |
90 | { | 90 | { |
91 | - var SurfaceType = await _surfaceTypeDs.GetSelectListAsync(); | ||
92 | - var StateCommon = await _stateCommonDs.GetSelectListAsync(); | ||
93 | - var Settlement = await _settlementDs.GetSelectListAsync(); | ||
94 | - var Road = await _roadDs.GetSelectListAsync(); | ||
95 | - var Region = await _regionDs.GetSelectListAsync(); | ||
96 | - | ||
97 | - CreateBusStopVm vm = new CreateBusStopVm | ||
98 | - { | ||
99 | - SurfaceTypeSelectListDsM = SurfaceType.ToList(), | ||
100 | - StateCommonSelectListDsM = StateCommon.ToList(), | ||
101 | - SettlementSelectListDsM = Settlement.ToList(), | ||
102 | - RoadSelectListDsM = Road.ToList(), | ||
103 | - RegionSelectListDsM = Region.ToList() | ||
104 | - }; | ||
105 | - return Json(vm); | 91 | + return Json(data); |
106 | } | 92 | } |
107 | 93 | ||
108 | - [HttpGet] | ||
109 | - public async Task<IActionResult> Update(int id, string data){ | ||
110 | - var SurfaceType = await _surfaceTypeDs.GetSelectListAsync(); | ||
111 | - var StateCommon = await _stateCommonDs.GetSelectListAsync(); | ||
112 | - var Settlement = await _settlementDs.GetSelectListAsync(); | ||
113 | - var Road = await _roadDs.GetSelectListAsync(); | ||
114 | - var Region = await _regionDs.GetSelectListAsync(); | ||
115 | - | ||
116 | - CreateBusStopVm vm = new CreateBusStopVm | ||
117 | - { | ||
118 | - SurfaceTypeSelectListDsM = SurfaceType.ToList(), | ||
119 | - StateCommonSelectListDsM = StateCommon.ToList(), | ||
120 | - SettlementSelectListDsM = Settlement.ToList(), | ||
121 | - RoadSelectListDsM = Road.ToList(), | ||
122 | - RegionSelectListDsM = Region.ToList() | ||
123 | - }; | ||
124 | - return Json(vm); | 94 | + [HttpPost] |
95 | + public IActionResult Update(int id, string data){ | ||
96 | + return Json(data); | ||
125 | } | 97 | } |
126 | 98 | ||
127 | // POST: BusStop/Create | 99 | // POST: BusStop/Create |
src/Maps/Startup.cs
@@ -37,7 +37,11 @@ namespace Maps | @@ -37,7 +37,11 @@ namespace Maps | ||
37 | // This method gets called by the runtime. Use this method to add services to the container. | 37 | // This method gets called by the runtime. Use this method to add services to the container. |
38 | public void ConfigureServices(IServiceCollection services) | 38 | public void ConfigureServices(IServiceCollection services) |
39 | { | 39 | { |
40 | - services.AddCors(); | 40 | + services.AddCors(o => o.AddPolicy("MyPolicy", builder => { |
41 | + builder.AllowAnyOrigin() | ||
42 | + .AllowAnyMethod() | ||
43 | + .AllowAnyHeader(); | ||
44 | + })); | ||
41 | services.AddScoped<PostgresDbContext>(); | 45 | services.AddScoped<PostgresDbContext>(); |
42 | 46 | ||
43 | services.AddScoped<IBusStopDs, BusStopDs>(); | 47 | services.AddScoped<IBusStopDs, BusStopDs>(); |
@@ -57,10 +61,7 @@ namespace Maps | @@ -57,10 +61,7 @@ namespace Maps | ||
57 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | 61 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
58 | { | 62 | { |
59 | 63 | ||
60 | - app.UseCors(builder => | ||
61 | - builder.WithOrigins("http://localhost:3000") | ||
62 | - .AllowAnyHeader() | ||
63 | - ); | 64 | + app.UseCors("MyPolicy"); |
64 | app.UseDeveloperExceptionPage(); | 65 | app.UseDeveloperExceptionPage(); |
65 | app.UseBrowserLink(); | 66 | app.UseBrowserLink(); |
66 | 67 |