forked from MDCPS/DamageAssessment_Backend
		
	314: updated document multi language output format
This commit is contained in:
		| @ -7,7 +7,6 @@ using Microsoft.AspNetCore.Mvc; | ||||
|  | ||||
| namespace DamageAssesment.Api.Documents.Controllers | ||||
| { | ||||
|     [Route("api")] | ||||
|     [ApiController] | ||||
|     public class DocumentsController : ControllerBase | ||||
|     { | ||||
| @ -25,10 +24,13 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Get all documnets. | ||||
|         /// </summary> | ||||
|         [HttpGet("{language}/{LinkType}/documents")] | ||||
|         public async Task<IActionResult> GetDocumentsbyFormsandLanguageAsync(string language,string LinkType) | ||||
|         ///  | ||||
|         [Route("doculinks/{linktype:alpha}")] | ||||
|         [Route("doculinks/{linktype:alpha}/{language:alpha}")] | ||||
|         [HttpGet] | ||||
|         public async Task<IActionResult> GetDocumentsbyFormsandLanguageAsync(string linktype, string? language) | ||||
|         { | ||||
|             var result = await this.documentsProvider.GetDocumnetsByLinkAsync(language, LinkType); | ||||
|             var result = await this.documentsProvider.GetDocumnetsByLinkAsync(language, linktype); | ||||
|             if (result.IsSuccess) | ||||
|             { | ||||
|                 return Ok(result.documents); | ||||
| @ -38,23 +40,13 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Get all documnets. | ||||
|         /// </summary> | ||||
|         [HttpGet("{LinkType}/documents")] | ||||
|         public async Task<IActionResult> GetDocumentsbyFormAsync(string LinkType) | ||||
|         ///  | ||||
|         //[Route("doculinks/{language:alpha}")] | ||||
|         [Route("doculinks")] | ||||
|         [HttpGet] | ||||
|         public async Task<IActionResult> GetDocumentsAsync(string? language) | ||||
|         { | ||||
|             var result = await this.documentsProvider.GetDocumnetsByLinkAsync(null, LinkType); | ||||
|             if (result.IsSuccess) | ||||
|             { | ||||
|                 return Ok(result.documents); | ||||
|             } | ||||
|             return NoContent(); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// Get all documnets. | ||||
|         /// </summary> | ||||
|         [HttpGet("documents")] | ||||
|         public async Task<IActionResult> GetDocumentsAsync() | ||||
|         { | ||||
|             var result = await this.documentsProvider.GetDocumnetsAsync(); | ||||
|             var result = await this.documentsProvider.GetDocumnetsAsync(language); | ||||
|             if (result.IsSuccess) | ||||
|             { | ||||
|                 return Ok(result.documents); | ||||
| @ -65,10 +57,12 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Get a documnet by id. | ||||
|         /// </summary> | ||||
|         [HttpGet("documents/{id}")] | ||||
|         public async Task<IActionResult> GetDocumentAsync(int id) | ||||
|         [HttpGet] | ||||
|         [Route("doculinks/{id}")] | ||||
|         [Route("doculinks/{id}/{language:alpha}")] | ||||
|         public async Task<IActionResult> GetDocumentAsync(int id,string? language) | ||||
|         { | ||||
|             var result = await this.documentsProvider.GetDocumentAsync(id); | ||||
|             var result = await this.documentsProvider.GetDocumentAsync(id,language); | ||||
|             if (result.IsSuccess) | ||||
|             { | ||||
|                 return Ok(result.Document); | ||||
| @ -78,30 +72,32 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Upload new document. | ||||
|         /// </summary> | ||||
|         [HttpPut("documents")] | ||||
|         public async Task<IActionResult> UpdateDocument(DocumentInfo documentInfo) | ||||
|         [HttpPut] | ||||
|         [Route("doculinks/{id}")] | ||||
|         public async Task<IActionResult> UpdateDocument(int id,DocumentInfo documentInfo) | ||||
|         { | ||||
|             if (documentInfo != null) | ||||
|             { | ||||
|                 var dbdoc = await this.documentsProvider.GetDocumentAsync(documentInfo.Id); | ||||
|                 var dbdoc = await this.documentsProvider.GetDocumentByidAsync(id); | ||||
|                 if (dbdoc.IsSuccess) | ||||
|                 { | ||||
|                     Models.Document document = uploadService.UpdateDocuments(dbdoc.Document, documentInfo); | ||||
|                     var result = await this.documentsProvider.UpdateDocumentAsync(document); | ||||
|                     var result = await this.documentsProvider.UpdateDocumentAsync(id,document); | ||||
|                     if (result.IsSuccess) | ||||
|                     { | ||||
|                         return Ok(result.Document); | ||||
|                     } | ||||
|                     return NoContent(); | ||||
|                 } | ||||
|                 return NoContent(); | ||||
|                 return NotFound(); | ||||
|             } | ||||
|             return BadRequest(documentInfo); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// update existing document. | ||||
|         /// </summary> | ||||
|         [HttpPost("documents")] | ||||
|         [HttpPost] | ||||
|         [Route("doculinks")] | ||||
|         public async Task<IActionResult> CreateDocument(DocumentInfo documentInfo) | ||||
|         { | ||||
|             try | ||||
| @ -127,7 +123,8 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Delete documnet by id. | ||||
|         /// </summary> | ||||
|         [HttpDelete("documents/{id}")] | ||||
|         [HttpDelete] | ||||
|         [Route("doculinks/{id}")] | ||||
|         public async Task<IActionResult> DeleteDocument(int id) | ||||
|         { | ||||
|             // database soft delete | ||||
| @ -143,7 +140,8 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Get all document link type. | ||||
|         /// </summary> | ||||
|         [HttpGet("LinkTypes")] | ||||
|         [HttpGet] | ||||
|         [Route("doculinks/types")] | ||||
|         public async Task<IActionResult> GetLinkTypesAsync() | ||||
|         { | ||||
|             var result = await this.documentsProvider.GetLinkTypesAsync(); | ||||
| @ -156,7 +154,8 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Get a document link type by id. | ||||
|         /// </summary> | ||||
|         [HttpGet("LinkTypes/{id}")] | ||||
|         [HttpGet] | ||||
|         [Route("doculinks/types/{id}")] | ||||
|         public async Task<IActionResult> GetLinkTypeAsync(int id) | ||||
|         { | ||||
|             var result = await this.documentsProvider.GetLinkTypeAsync(id); | ||||
| @ -169,7 +168,8 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Update a existing document link type. | ||||
|         /// </summary> | ||||
|         [HttpPut("LinkTypes")] | ||||
|         [HttpPut] | ||||
|         [Route("doculinks/types")] | ||||
|         public async Task<IActionResult> UpdateLinkType(Models.LinkType linkType) | ||||
|         { | ||||
|             if (linkType != null) | ||||
| @ -189,7 +189,8 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Create a new document link type. | ||||
|         /// </summary> | ||||
|         [HttpPost("LinkTypes")] | ||||
|         [HttpPost] | ||||
|         [Route("doculinks/types")] | ||||
|         public async Task<IActionResult> CreateLinkType(Models.LinkType linkType) | ||||
|         { | ||||
|             if (linkType != null) | ||||
| @ -206,7 +207,8 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|         /// <summary> | ||||
|         /// Delete a  existing document link type by id. | ||||
|         /// </summary> | ||||
|         [HttpDelete("LinkTypes/{id}")] | ||||
|         [HttpDelete] | ||||
|         [Route("doculinks/types/{id}")] | ||||
|         public async Task<IActionResult> DeleteLinkType(int id) | ||||
|         { | ||||
|             var result = await this.documentsProvider.DeleteLinkTypeAsync(id); | ||||
| @ -216,7 +218,5 @@ namespace DamageAssesment.Api.Documents.Controllers | ||||
|             } | ||||
|             return NotFound(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user