forked from MDCPS/DamageAssessment_Backend
		
	Fix for Data seed issue,Url Correction for SurveyResponses
This commit is contained in:
		| @ -4,7 +4,8 @@ using Microsoft.AspNetCore.Mvc; | ||||
|  | ||||
| namespace DamageAssesment.Api.Locations.Controllers | ||||
| { | ||||
|     //[Route("api")] | ||||
|     [Route("Locations")] | ||||
|     //[Route("[controller]")] | ||||
|     [ApiController] | ||||
|     public class LocationsController : ControllerBase | ||||
|     { | ||||
| @ -18,7 +19,8 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// Get all locations. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpGet("Locations")] | ||||
|         //[HttpGet("locations")] | ||||
|         [HttpGet] | ||||
|         public async Task<ActionResult> GetLocationsAsync() | ||||
|         { | ||||
|  | ||||
| @ -34,7 +36,7 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// Get all locations based on locationdId. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpGet("Locations/{id}")] | ||||
|         [HttpGet("{id}")] | ||||
|         public async Task<ActionResult> GetLocationByIdAsync(string id) | ||||
|         { | ||||
|  | ||||
| @ -50,12 +52,12 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// Update a Location. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpPut("Locations")] | ||||
|         public async Task<IActionResult> UpdateLocation(Models.Location Location) | ||||
|         [HttpPut("{locations}")] | ||||
|         public async Task<IActionResult> UpdateLocation(Models.Location location) | ||||
|         { | ||||
|             if (Location != null) | ||||
|             if (location != null) | ||||
|             { | ||||
|                 var result = await this.LocationProvider.UpdateLocationAsync(Location); | ||||
|                 var result = await this.LocationProvider.UpdateLocationAsync(location); | ||||
|                 if (result.IsSuccess) | ||||
|                 { | ||||
|                     return Ok(result.ErrorMessage); | ||||
| @ -68,7 +70,7 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// Save a new location. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpPost("Locations")] | ||||
|         [HttpPost("{locations}")] | ||||
|         public async Task<IActionResult> CreateLocation(Models.Location Location) | ||||
|         { | ||||
|             if (Location != null) | ||||
| @ -86,7 +88,7 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// Delete an existing location. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpDelete("Locations/{id}")] | ||||
|         [HttpDelete("{id}")] | ||||
|         public async Task<IActionResult> DeleteLocation(string id) | ||||
|         { | ||||
|             var result = await this.LocationProvider.DeleteLocationAsync(id); | ||||
|  | ||||
| @ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; | ||||
| namespace DamageAssesment.Api.Locations.Controllers | ||||
| { | ||||
|     //[Route("api/[controller]")] | ||||
|     [Route("[controller]")] | ||||
|     [ApiController] | ||||
|     public class RegionsController : ControllerBase | ||||
|     { | ||||
| @ -45,7 +46,7 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// POST request for creating a new region. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpPost] | ||||
|         [HttpPost("{region}")] | ||||
|         public async Task<ActionResult> PostRegionAsync(Models.Region region) | ||||
|         { | ||||
|             var result = await this.regionProvider.PostRegionAsync(region); | ||||
| @ -59,7 +60,7 @@ namespace DamageAssesment.Api.Locations.Controllers | ||||
|         /// PUT request for updating an existing region. | ||||
|         /// </summary> | ||||
|  | ||||
|         [HttpPut] | ||||
|         [HttpPut("{region}")] | ||||
|         public async Task<ActionResult> PutRegionAsync(Models.Region region) | ||||
|         { | ||||
|             var result = await this.regionProvider.PutRegionAsync(region); | ||||
|  | ||||
| @ -9,5 +9,6 @@ namespace DamageAssesment.Api.Locations.Interfaces | ||||
|         Task<(bool IsSuccess, Models.Location Question, string ErrorMessage)> PostLocationAsync(Models.Location Location); | ||||
|         Task<(bool IsSuccess, string ErrorMessage)> UpdateLocationAsync(Models.Location Location); | ||||
|         Task<(bool IsSuccess, string ErrorMessage)> DeleteLocationAsync(string Id); | ||||
|         void SeedData(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -7,5 +7,6 @@ | ||||
|         Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> PostRegionAsync(Models.Region region); | ||||
|         Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> PutRegionAsync(Models.Region region); | ||||
|         Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> DeleteRegionAsync(string Id); | ||||
|         void SeedData(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -31,10 +31,24 @@ var app = builder.Build(); | ||||
| // Configure the HTTP request pipeline. | ||||
| if (app.Environment.IsDevelopment()) | ||||
| { | ||||
|     using (var serviceScope = app.Services.CreateScope()) | ||||
|     { | ||||
|         var services = serviceScope.ServiceProvider; | ||||
|         var locationProvider = services.GetRequiredService<ILocationsProvider>(); | ||||
|         var regionProvider = services.GetRequiredService<IRegionsProvider>(); | ||||
|         locationProvider.SeedData(); | ||||
|         regionProvider.SeedData(); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     app.UseSwagger(); | ||||
|     app.UseSwaggerUI(options => | ||||
|     { | ||||
|         options.SwaggerEndpoint("/locations/swagger/v1/swagger.json", ""); | ||||
|         //switch for local environment | ||||
|         //options.SwaggerEndpoint("/swagger/v1/swagger.json",""); | ||||
|         options.SwaggerEndpoint("locations/swagger/v1/swagger.json", "");  | ||||
|         | ||||
|  | ||||
|     }); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -17,7 +17,7 @@ namespace DamageAssesment.Api.Locations.Providers | ||||
|             this.locationDbContext = locationDbContext; | ||||
|             this.logger = logger; | ||||
|             this.mapper = mapper; | ||||
|             SeedData(); | ||||
|             //SeedData(); | ||||
|         } | ||||
|  | ||||
|         public async Task<(bool IsSuccess, IEnumerable<Models.Location> locations, string ErrorMessage)> GetLocationsAsync() | ||||
| @ -127,7 +127,7 @@ namespace DamageAssesment.Api.Locations.Providers | ||||
|         { | ||||
|             return locationDbContext.Locations.AsNoTracking().Count(e => e.Id == id) > 0; | ||||
|         } | ||||
|         private void SeedData() | ||||
|         public void SeedData() | ||||
|         { | ||||
|             if (!locationDbContext.Locations.Any()) | ||||
|             { | ||||
|  | ||||
| @ -17,7 +17,7 @@ namespace DamageAssesment.Api.Locations.Providers | ||||
|             this.locationDbContext = regionDbContext; | ||||
|             this.logger = logger; | ||||
|             this.mapper = mapper; | ||||
|             SeedData(); | ||||
|            // SeedData(); | ||||
|         } | ||||
|  | ||||
|         public async Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> GetRegionByIdAsync(string Id) | ||||
| @ -150,7 +150,7 @@ namespace DamageAssesment.Api.Locations.Providers | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         private void SeedData() | ||||
|         public void SeedData() | ||||
|         { | ||||
|             if (!locationDbContext.Regions.Any()) | ||||
|             { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user