forked from MDCPS/DamageAssessment_Backend
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			server-bra
			...
			DocumentsA
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3b91282419 | |||
| b878cd706c | 
@ -21,7 +21,7 @@
 | 
				
			|||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <ProjectReference Include="..\DamageAssesment.Api.Documents\DamageAssesment.Api.Documents.csproj" />
 | 
					    <ProjectReference Include="..\DamageAssesment.Api.Documents\DamageAssesment.Api.DocuLinks.csproj" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</Project>
 | 
					</Project>
 | 
				
			||||||
@ -17,10 +17,10 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
					            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
				
			||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getNoContentResponse();
 | 
					            var mockResponse = await MockData.getNoContentResponse();
 | 
				
			||||||
            mockDocumentService.Setup(service => service.GetDocumnetsAsync()).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms","en")).ReturnsAsync(mockResponse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (NoContentResult)await DocumentProvider.GetDocumentsbyFormsandLanguageAsync("", "");
 | 
					            var result = (NoContentResult)await DocumentProvider.GetDocumentsAsync("", "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(204, result.StatusCode);
 | 
					            Assert.Equal(204, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -31,10 +31,10 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
					            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
				
			||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getNoContentResponse();
 | 
					            var mockResponse = await MockData.getNoContentResponse();
 | 
				
			||||||
            mockDocumentService.Setup(service => service.GetDocumnetsAsync()).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms","en")).ReturnsAsync(mockResponse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (NoContentResult)await DocumentProvider.GetDocumentsbyFormsandLanguageAsync("", "");
 | 
					            var result = (NoContentResult)await DocumentProvider.GetDocumentsAsync("", "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(204, result.StatusCode);
 | 
					            Assert.Equal(204, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -44,10 +44,10 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
					            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
				
			||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getOkResponse();
 | 
					            var mockResponse = await MockData.getOkResponse();
 | 
				
			||||||
            mockDocumentService.Setup(service => service.GetDocumnetsAsync()).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms","en")).ReturnsAsync(mockResponse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (OkObjectResult)await DocumentProvider.GetDocumentsAsync();
 | 
					            var result = (OkObjectResult)await DocumentProvider.GetDocumentsAsync("forms","en");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(200, result.StatusCode);
 | 
					            Assert.Equal(200, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -58,10 +58,10 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
					            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
				
			||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getNoContentResponse();
 | 
					            var mockResponse = await MockData.getNoContentResponse();
 | 
				
			||||||
            mockDocumentService.Setup(service => service.GetDocumnetsAsync()).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms", "en")).ReturnsAsync(mockResponse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (NoContentResult)await DocumentProvider.GetDocumentsAsync();
 | 
					            var result = (NoContentResult)await DocumentProvider.GetDocumentsAsync("forms","en");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(204, result.StatusCode);
 | 
					            Assert.Equal(204, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -72,10 +72,10 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
					            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
				
			||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getOkResponse(1);
 | 
					            var mockResponse = await MockData.getOkResponse(1);
 | 
				
			||||||
            mockDocumentService.Setup(service => service.GetDocumentAsync(1)).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.GetDocumentAsync(1,"forms","en")).ReturnsAsync(mockResponse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (OkObjectResult)await DocumentProvider.GetDocumentAsync(1);
 | 
					            var result = (OkObjectResult)await DocumentProvider.GetDocumentAsync(1, "forms", "en");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(200, result.StatusCode);
 | 
					            Assert.Equal(200, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -86,9 +86,9 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
					            var mockDocumentService = new Mock<IDocumentsProvider>();
 | 
				
			||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getNotFoundResponse();
 | 
					            var mockResponse = await MockData.getNotFoundResponse();
 | 
				
			||||||
            mockDocumentService.Setup(service => service.GetDocumentAsync(99)).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.GetDocumentAsync(99, "forms", "en")).ReturnsAsync(mockResponse);
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (NotFoundResult)await DocumentProvider.GetDocumentAsync(99);
 | 
					            var result = (NotFoundResult)await DocumentProvider.GetDocumentAsync(99, "forms", "en");
 | 
				
			||||||
            Assert.Equal(404, result.StatusCode);
 | 
					            Assert.Equal(404, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        [Fact(DisplayName = "Post Document - Ok case")]
 | 
					        [Fact(DisplayName = "Post Document - Ok case")]
 | 
				
			||||||
@ -129,11 +129,11 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockResponse = await MockData.getOkResponse(1);
 | 
					            var mockResponse = await MockData.getOkResponse(1);
 | 
				
			||||||
            var mockInputDocument = await MockData.getInputDocumentData();
 | 
					            var mockInputDocument = await MockData.getInputDocumentData();
 | 
				
			||||||
            var DocumentResponse = await MockData.GetDocumentsInfo(1);
 | 
					            var DocumentResponse = await MockData.GetDocumentsInfo(1);
 | 
				
			||||||
            mockDocumentService.Setup(service => service.UpdateDocumentAsync(mockInputDocument)).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.UpdateDocumentAsync(1,mockInputDocument)).ReturnsAsync(mockResponse);
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (NoContentResult)await DocumentProvider.UpdateDocument(DocumentResponse);
 | 
					            var result = (NotFoundResult)await DocumentProvider.UpdateDocument(1,DocumentResponse);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Assert.Equal(204, result.StatusCode);
 | 
					            Assert.Equal(404, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Fact(DisplayName = "Put Document - BadRequest case")]
 | 
					        [Fact(DisplayName = "Put Document - BadRequest case")]
 | 
				
			||||||
@ -143,9 +143,9 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
            var mockUploadService = new Mock<IUploadService>();
 | 
					            var mockUploadService = new Mock<IUploadService>();
 | 
				
			||||||
            var mockResponse = await MockData.getBadRequestResponse();
 | 
					            var mockResponse = await MockData.getBadRequestResponse();
 | 
				
			||||||
            var mockInputDocument = await MockData.getInputDocumentData();
 | 
					            var mockInputDocument = await MockData.getInputDocumentData();
 | 
				
			||||||
            mockDocumentService.Setup(service => service.UpdateDocumentAsync(mockInputDocument)).ReturnsAsync(mockResponse);
 | 
					            mockDocumentService.Setup(service => service.UpdateDocumentAsync(99,mockInputDocument)).ReturnsAsync(mockResponse);
 | 
				
			||||||
            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
					            var DocumentProvider = new DocumentsController(mockDocumentService.Object, mockUploadService.Object);
 | 
				
			||||||
            var result = (BadRequestObjectResult)await DocumentProvider.UpdateDocument(null);
 | 
					            var result = (BadRequestObjectResult)await DocumentProvider.UpdateDocument(99,null);
 | 
				
			||||||
            Assert.Equal(400, result.StatusCode);
 | 
					            Assert.Equal(400, result.StatusCode);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -11,12 +11,16 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
    public class MockData
 | 
					    public class MockData
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static async Task<(bool, List<Documents.Models.Document>, string)> getOkResponse()
 | 
					        public static async Task<(bool, List<Documents.Models.MultiLanDocument>, string)> getOkResponse()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            List<Documents.Models.Document> list = new List<Documents.Models.Document>();
 | 
					            List<Documents.Models.MultiLanDocument> list = new List<Documents.Models.MultiLanDocument>();
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            for (int i = 1; i < 4; i++)
 | 
					            for (int i = 1; i < 4; i++)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                Dictionary<string, string> dicttitle = new Dictionary<string, string>();
 | 
				
			||||||
 | 
					                Dictionary<string, string> dictdesc = new Dictionary<string, string>(); 
 | 
				
			||||||
 | 
					                dicttitle.Add("en", "test"); dicttitle.Add("fr", "tester");
 | 
				
			||||||
 | 
					                dictdesc.Add("en", "test"); dictdesc.Add("fr", "tester");
 | 
				
			||||||
                List<Documents.Models.DocumentsTranslation> documentsTranslations = new List<DocumentsTranslation>();
 | 
					                List<Documents.Models.DocumentsTranslation> documentsTranslations = new List<DocumentsTranslation>();
 | 
				
			||||||
                documentsTranslations.Add(new DocumentsTranslation()
 | 
					                documentsTranslations.Add(new DocumentsTranslation()
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@ -24,7 +28,7 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
                    title = "tel"+i,
 | 
					                    title = "tel"+i,
 | 
				
			||||||
                    description = "Sample"+i
 | 
					                    description = "Sample"+i
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                list.Add(new Documents.Models.Document()
 | 
					                list.Add(new Documents.Models.MultiLanDocument()
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Id = i,
 | 
					                    Id = i,
 | 
				
			||||||
@ -33,32 +37,33 @@ namespace DamageAssesment.Api.Documents.Test
 | 
				
			|||||||
                    url = "testurl" + i,
 | 
					                    url = "testurl" + i,
 | 
				
			||||||
                    Path = "testpath" + i,
 | 
					                    Path = "testpath" + i,
 | 
				
			||||||
                    IsActive = true,
 | 
					                    IsActive = true,
 | 
				
			||||||
                    documentsTranslations= documentsTranslations,
 | 
					                    titles= dicttitle,
 | 
				
			||||||
 | 
					                    description=dictdesc,
 | 
				
			||||||
                    dateCreated = DateTime.Now,
 | 
					                    dateCreated = DateTime.Now,
 | 
				
			||||||
                    dateUpdated = DateTime.Now
 | 
					                    dateUpdated = DateTime.Now
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return (true, list, null);
 | 
					            return (true, list, null);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public static async Task<(bool, Documents.Models.Document, string)> getOkResponse(int Id)
 | 
					        public static async Task<(bool, Documents.Models.MultiLanDocument, string)> getOkResponse(int Id)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var Documents = await getOkResponse();
 | 
					            var Documents = await getOkResponse();
 | 
				
			||||||
            var Document = Documents.Item2.FirstOrDefault(s => s.Id == Id);
 | 
					            var Document = Documents.Item2.FirstOrDefault(s => s.Id == Id);
 | 
				
			||||||
            return (true, Document, null);
 | 
					            return (true, Document, null);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static async Task<(bool, Documents.Models.Document, string)> getBadRequestResponse()
 | 
					        public static async Task<(bool, Documents.Models.MultiLanDocument, string)> getBadRequestResponse()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return (false, null, "Bad Request");
 | 
					            return (false, null, "Bad Request");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static async Task<(bool, Documents.Models.Document, string)> getNotFoundResponse()
 | 
					        public static async Task<(bool, Documents.Models.MultiLanDocument, string)> getNotFoundResponse()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return (false, null, "Not Found");
 | 
					            return (false, null, "Not Found");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public static async Task<(bool, IEnumerable<Documents.Models.Document>, string)> getNoContentResponse()
 | 
					        public static async Task<(bool, IEnumerable<Documents.Models.MultiLanDocument>, string)> getNoContentResponse()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            IEnumerable<Documents.Models.Document> list = new List<Documents.Models.Document>();
 | 
					            IEnumerable<Documents.Models.MultiLanDocument> list = new List<Documents.Models.MultiLanDocument>();
 | 
				
			||||||
            return (false, list, null);
 | 
					            return (false, list, null);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public static async Task<Documents.Models.DocumentInfo> GetDocumentsInfo(int id)
 | 
					        public static async Task<Documents.Models.DocumentInfo> GetDocumentsInfo(int id)
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Mvc;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace DamageAssesment.Api.Documents.Controllers
 | 
					namespace DamageAssesment.Api.Documents.Controllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    [Route("api")]
 | 
					 | 
				
			||||||
    [ApiController]
 | 
					    [ApiController]
 | 
				
			||||||
    public class DocumentsController : ControllerBase
 | 
					    public class DocumentsController : ControllerBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -21,54 +20,131 @@ namespace DamageAssesment.Api.Documents.Controllers
 | 
				
			|||||||
            this.uploadService = uploadService; 
 | 
					            this.uploadService = uploadService; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Get all document link type.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [HttpGet]
 | 
				
			||||||
 | 
					        [Route("doculinks/types")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> GetLinkTypesAsync()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var result = await this.documentsProvider.GetLinkTypesAsync();
 | 
				
			||||||
 | 
					            if (result.IsSuccess)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Ok(result.LinkTypes);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return NoContent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Get a document link type by id.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [HttpGet]
 | 
				
			||||||
 | 
					        [Route("doculinks/types/{id}")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> GetLinkTypeAsync(int id)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var result = await this.documentsProvider.GetLinkTypeAsync(id);
 | 
				
			||||||
 | 
					            if (result.IsSuccess)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Ok(result.LinkType);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Update a existing document link type.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [HttpPut]
 | 
				
			||||||
 | 
					        [Route("doculinks/types")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> UpdateLinkType(Models.LinkType linkType)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (linkType != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var result = await this.documentsProvider.UpdateLinkTypeAsync(linkType);
 | 
				
			||||||
 | 
					                if (result.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Ok(result.LinkType);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (result.ErrorMessage == "Not Found")
 | 
				
			||||||
 | 
					                    return NotFound(result.ErrorMessage);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return BadRequest(result.ErrorMessage);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return CreatedAtRoute("DefaultApi", new { id = linkType.Id }, linkType);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Create a new document link type.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        [Route("doculinks/types")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> CreateLinkType(Models.LinkType linkType)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (linkType != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var result = await this.documentsProvider.PostLinkTypeAsync(linkType);
 | 
				
			||||||
 | 
					                if (result.IsSuccess)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return Ok(result.LinkType);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return BadRequest(result.ErrorMessage);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return CreatedAtRoute("DefaultApi", new { id = linkType.Id }, linkType);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Delete a  existing document link type by id.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [HttpDelete]
 | 
				
			||||||
 | 
					        [Route("doculinks/types/{id}")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> DeleteLinkType(int id)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var result = await this.documentsProvider.DeleteLinkTypeAsync(id);
 | 
				
			||||||
 | 
					            if (result.IsSuccess)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Ok(result.LinkType);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					            /// <summary>
 | 
				
			||||||
 | 
					            /// Get all documents.
 | 
				
			||||||
 | 
					            /// </summary>
 | 
				
			||||||
 | 
					            /// 
 | 
				
			||||||
 | 
					            [Route("doculinks")]
 | 
				
			||||||
 | 
					        [Route("doculinks/{linktype:alpha}")]
 | 
				
			||||||
 | 
					        [Route("doculinks/{linktype:alpha}/{language:alpha}")]
 | 
				
			||||||
 | 
					        [HttpGet]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> GetDocumentsAsync(string? linktype, string? language)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var result = await this.documentsProvider.GetdocumentsByLinkAsync(linktype, language);
 | 
				
			||||||
 | 
					            if (result.IsSuccess)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return Ok(result.documents);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return NoContent();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Get all documents.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// 
 | 
				
			||||||
 | 
					        //[Route("doculinks/{language:alpha}")]
 | 
				
			||||||
 | 
					        //[Route("doculinks")]
 | 
				
			||||||
 | 
					        //[HttpGet]
 | 
				
			||||||
 | 
					        //public async Task<IActionResult> GetDocumentsAsync(string? language)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    var result = await this.documentsProvider.GetdocumentsAsync(language);
 | 
				
			||||||
 | 
					        //    if (result.IsSuccess)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        return Ok(result.documents);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //    return NoContent();
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Get all documnets.
 | 
					        /// Get a document by id.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [HttpGet("{language}/{LinkType}/documents")]
 | 
					        [HttpGet]
 | 
				
			||||||
        public async Task<IActionResult> GetDocumentsbyFormsandLanguageAsync(string language,string LinkType)
 | 
					        [Route("doculinks/{id}")]
 | 
				
			||||||
 | 
					        [Route("doculinks/{id}/{linktype:alpha}")]
 | 
				
			||||||
 | 
					        [Route("doculinks/{id}/{linktype:alpha}/{language:alpha}")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> GetDocumentAsync(int id,string? linktype, string? language)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var result = await this.documentsProvider.GetDocumnetsByLinkAsync(language, LinkType);
 | 
					            var result = await this.documentsProvider.GetDocumentAsync(id, linktype, language);
 | 
				
			||||||
            if (result.IsSuccess)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return Ok(result.documents);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return NoContent();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Get all documnets.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpGet("{LinkType}/documents")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> GetDocumentsbyFormAsync(string LinkType)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            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();
 | 
					 | 
				
			||||||
            if (result.IsSuccess)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return Ok(result.documents);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return NoContent();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Get a documnet by id.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpGet("documents/{id}")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> GetDocumentAsync(int id)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var result = await this.documentsProvider.GetDocumentAsync(id);
 | 
					 | 
				
			||||||
            if (result.IsSuccess)
 | 
					            if (result.IsSuccess)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return Ok(result.Document);
 | 
					                return Ok(result.Document);
 | 
				
			||||||
@ -78,30 +154,32 @@ namespace DamageAssesment.Api.Documents.Controllers
 | 
				
			|||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Upload new document.
 | 
					        /// Upload new document.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [HttpPut("documents")]
 | 
					        [HttpPut]
 | 
				
			||||||
        public async Task<IActionResult> UpdateDocument(DocumentInfo documentInfo)
 | 
					        [Route("doculinks/{id}")]
 | 
				
			||||||
 | 
					        public async Task<IActionResult> UpdateDocument(int id,DocumentInfo documentInfo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (documentInfo != null)
 | 
					            if (documentInfo != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                var dbdoc = await this.documentsProvider.GetDocumentAsync(documentInfo.Id);
 | 
					                var dbdoc = await this.documentsProvider.GetDocumentByidAsync(id);
 | 
				
			||||||
                if (dbdoc.IsSuccess)
 | 
					                if (dbdoc.IsSuccess)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Models.Document document = uploadService.UpdateDocuments(dbdoc.Document, documentInfo);
 | 
					                    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)
 | 
					                    if (result.IsSuccess)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        return Ok(result.Document);
 | 
					                        return Ok(result.Document);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return NoContent();
 | 
					                    return NoContent();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return NoContent();
 | 
					                return NotFound();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return BadRequest(documentInfo);
 | 
					            return BadRequest(documentInfo);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// update existing document.
 | 
					        /// update existing document.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [HttpPost("documents")]
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        [Route("doculinks")]
 | 
				
			||||||
        public async Task<IActionResult> CreateDocument(DocumentInfo documentInfo)
 | 
					        public async Task<IActionResult> CreateDocument(DocumentInfo documentInfo)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
@ -125,9 +203,10 @@ namespace DamageAssesment.Api.Documents.Controllers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Delete documnet by id.
 | 
					        /// Delete document by id.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        [HttpDelete("documents/{id}")]
 | 
					        [HttpDelete]
 | 
				
			||||||
 | 
					        [Route("doculinks/{id}")]
 | 
				
			||||||
        public async Task<IActionResult> DeleteDocument(int id)
 | 
					        public async Task<IActionResult> DeleteDocument(int id)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // database soft delete
 | 
					            // database soft delete
 | 
				
			||||||
@ -140,83 +219,6 @@ namespace DamageAssesment.Api.Documents.Controllers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            return NotFound();
 | 
					            return NotFound();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /// <summary>
 | 
					        
 | 
				
			||||||
        /// Get all document link type.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpGet("LinkTypes")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> GetLinkTypesAsync()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var result = await this.documentsProvider.GetLinkTypesAsync();
 | 
					 | 
				
			||||||
            if (result.IsSuccess)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return Ok(result.LinkTypes);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return NoContent();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Get a document link type by id.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpGet("LinkTypes/{id}")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> GetLinkTypeAsync(int id)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var result = await this.documentsProvider.GetLinkTypeAsync(id);
 | 
					 | 
				
			||||||
            if (result.IsSuccess)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return Ok(result.LinkType);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return NotFound();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Update a existing document link type.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpPut("LinkTypes")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> UpdateLinkType(Models.LinkType linkType)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (linkType != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                var result = await this.documentsProvider.UpdateLinkTypeAsync(linkType);
 | 
					 | 
				
			||||||
                if (result.IsSuccess)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    return Ok(result.LinkType);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                if (result.ErrorMessage == "Not Found")
 | 
					 | 
				
			||||||
                    return NotFound(result.ErrorMessage);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                return BadRequest(result.ErrorMessage);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return CreatedAtRoute("DefaultApi", new { id = linkType.Id }, linkType);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Create a new document link type.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpPost("LinkTypes")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> CreateLinkType(Models.LinkType linkType)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (linkType != null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                var result = await this.documentsProvider.PostLinkTypeAsync(linkType);
 | 
					 | 
				
			||||||
                if (result.IsSuccess)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    return Ok(result.LinkType);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                return BadRequest(result.ErrorMessage);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return CreatedAtRoute("DefaultApi", new { id = linkType.Id }, linkType);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					 | 
				
			||||||
        /// Delete a  existing document link type by id.
 | 
					 | 
				
			||||||
        /// </summary>
 | 
					 | 
				
			||||||
        [HttpDelete("LinkTypes/{id}")]
 | 
					 | 
				
			||||||
        public async Task<IActionResult> DeleteLinkType(int id)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var result = await this.documentsProvider.DeleteLinkTypeAsync(id);
 | 
					 | 
				
			||||||
            if (result.IsSuccess)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return Ok(result.LinkType);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return NotFound();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@
 | 
				
			|||||||
    <TargetFramework>net6.0</TargetFramework>
 | 
					    <TargetFramework>net6.0</TargetFramework>
 | 
				
			||||||
    <Nullable>enable</Nullable>
 | 
					    <Nullable>enable</Nullable>
 | 
				
			||||||
    <ImplicitUsings>enable</ImplicitUsings>
 | 
					    <ImplicitUsings>enable</ImplicitUsings>
 | 
				
			||||||
 | 
					    <GenerateDocumentationFile>True</GenerateDocumentationFile>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
@ -9,6 +9,7 @@ namespace DamageAssesment.Api.Documents.Db
 | 
				
			|||||||
        public int Id { get; set; }
 | 
					        public int Id { get; set; }
 | 
				
			||||||
        [ForeignKey("LinkType")]
 | 
					        [ForeignKey("LinkType")]
 | 
				
			||||||
        public int linkTypeId { get; set; }
 | 
					        public int linkTypeId { get; set; }
 | 
				
			||||||
 | 
					        public LinkType? LinkType { get; set; }
 | 
				
			||||||
        public string docName { get; set; }
 | 
					        public string docName { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string url { get; set; }
 | 
					        public string url { get; set; }
 | 
				
			||||||
 | 
				
			|||||||
@ -4,12 +4,13 @@ namespace DamageAssesment.Api.Documents.Interfaces
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public interface IDocumentsProvider : ILinkTypesProvider
 | 
					    public interface IDocumentsProvider : ILinkTypesProvider
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> GetDocumentAsync(int Id);
 | 
					        Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> GetDocumentAsync(int id, string? linktype, string? language);
 | 
				
			||||||
        Task<(bool IsSuccess, IEnumerable<Models.Document> documents, string ErrorMessage)> GetDocumnetsAsync();
 | 
					        Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> GetDocumentByidAsync(int id);
 | 
				
			||||||
        Task<(bool IsSuccess, IEnumerable<Models.Document> documents, string ErrorMessage)> GetDocumnetsByLinkAsync(string Language,string LinkType);
 | 
					       // Task<(bool IsSuccess, IEnumerable<Models.MultiLanDocument> documents, string ErrorMessage)> GetDocumnetsAsync(string? language);
 | 
				
			||||||
        Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> PostDocumentAsync(Models.Document Document);
 | 
					        Task<(bool IsSuccess, IEnumerable<Models.MultiLanDocument> documents, string ErrorMessage)> GetdocumentsByLinkAsync(string? linkType, string? language);
 | 
				
			||||||
        Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> UpdateDocumentAsync(Models.Document Document);
 | 
					        Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> PostDocumentAsync(Models.Document Document);
 | 
				
			||||||
        Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> DeleteDocumentAsync(int Id);
 | 
					        Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> UpdateDocumentAsync(int id,Models.Document Document);
 | 
				
			||||||
 | 
					        Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> DeleteDocumentAsync(int id);
 | 
				
			||||||
        Task<(bool IsSuccess, int counter, string message)> GetDocumentCounter();
 | 
					        Task<(bool IsSuccess, int counter, string message)> GetDocumentCounter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace DamageAssesment.Api.Documents.Models
 | 
					namespace DamageAssesment.Api.Documents.Models
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class Document
 | 
					    public class Document : BaseDocument
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public List<DocumentsTranslation> documentsTranslations { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public class MultiLanDocument:BaseDocument
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object titles { get; set; }
 | 
				
			||||||
 | 
					        public object description { get; set; }
 | 
				
			||||||
 | 
					        public string LinkType { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public class BaseDocument
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public int Id { get; set; }
 | 
					        public int Id { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -14,6 +24,5 @@ namespace DamageAssesment.Api.Documents.Models
 | 
				
			|||||||
        public bool IsActive { get; set; }
 | 
					        public bool IsActive { get; set; }
 | 
				
			||||||
        public DateTime dateCreated { get; set; }
 | 
					        public DateTime dateCreated { get; set; }
 | 
				
			||||||
        public DateTime dateUpdated { get; set; }
 | 
					        public DateTime dateUpdated { get; set; }
 | 
				
			||||||
        public List<DocumentsTranslation> documentsTranslations { get; set; }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,8 @@ namespace DamageAssesment.Api.Documents.Profiles
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        public DocumentProfile()
 | 
					        public DocumentProfile()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            CreateMap<Db.Document, Models.MultiLanDocument>().ForMember(dest => dest.LinkType,
 | 
				
			||||||
 | 
					                opt => opt.MapFrom(src => src.LinkType.TypeText)); ;
 | 
				
			||||||
            CreateMap<Db.Document, Models.Document>();
 | 
					            CreateMap<Db.Document, Models.Document>();
 | 
				
			||||||
            CreateMap<Models.Document, Db.Document>();
 | 
					            CreateMap<Models.Document, Db.Document>();
 | 
				
			||||||
            CreateMap<Db.LinkType, Models.LinkType>();
 | 
					            CreateMap<Db.LinkType, Models.LinkType>();
 | 
				
			||||||
 | 
				
			|||||||
@ -2,12 +2,20 @@ using DamageAssesment.Api.Documents.Db;
 | 
				
			|||||||
using DamageAssesment.Api.Documents.Interfaces;
 | 
					using DamageAssesment.Api.Documents.Interfaces;
 | 
				
			||||||
using DamageAssesment.Api.Documents.Providers;
 | 
					using DamageAssesment.Api.Documents.Providers;
 | 
				
			||||||
using Microsoft.EntityFrameworkCore;
 | 
					using Microsoft.EntityFrameworkCore;
 | 
				
			||||||
 | 
					using System.Reflection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var builder = WebApplication.CreateBuilder(args);
 | 
					var builder = WebApplication.CreateBuilder(args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Add services to the container.
 | 
					// Add services to the container.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
builder.Services.AddControllers();
 | 
					builder.Services.AddControllers();
 | 
				
			||||||
 | 
					builder.Services.AddSwaggerGen(c =>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Include XML comments from your assembly
 | 
				
			||||||
 | 
					    var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
 | 
				
			||||||
 | 
					    var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
 | 
				
			||||||
 | 
					    c.IncludeXmlComments(xmlPath);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 | 
					// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 | 
				
			||||||
builder.Services.AddEndpointsApiExplorer();
 | 
					builder.Services.AddEndpointsApiExplorer();
 | 
				
			||||||
builder.Services.AddSwaggerGen();
 | 
					builder.Services.AddSwaggerGen();
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
 | 
				
			|||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
 | 
					using Microsoft.EntityFrameworkCore.Metadata.Internal;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Diagnostics.Eventing.Reader;
 | 
					using System.Diagnostics.Eventing.Reader;
 | 
				
			||||||
 | 
					using System.Reflection.Metadata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DamageAssesment.Api.Documents.Providers
 | 
					namespace DamageAssesment.Api.Documents.Providers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -54,29 +55,55 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
                DocumentDbContext.SaveChanges();
 | 
					                DocumentDbContext.SaveChanges();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public async Task<(bool IsSuccess, IEnumerable<Models.Document> documents, string ErrorMessage)> GetDocumnetsByLinkAsync(string Language, string LinkType)
 | 
					        public List<Models.DocumentsTranslation> GetDocumentTranslations(int id, string? language)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<Models.DocumentsTranslation> QuestionTranslations;
 | 
				
			||||||
 | 
					            if (string.IsNullOrEmpty(language))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                QuestionTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
				
			||||||
 | 
					                    DocumentDbContext.DocumentsTranslations.AsNoTracking().Where(a => a.DocumentId == id).ToList());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                QuestionTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
				
			||||||
 | 
					                DocumentDbContext.DocumentsTranslations.AsNoTracking().Where(a => a.DocumentId == id && a.Language == language).ToList());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return QuestionTranslations;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public MultiLanDocument CreateMultiLanguageObject(List<Models.DocumentsTranslation> questions)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            MultiLanDocument MultiLanguage = new MultiLanDocument();
 | 
				
			||||||
 | 
					            Dictionary<string, string> dicttitle = new Dictionary<string, string>();
 | 
				
			||||||
 | 
					            Dictionary<string, string> dictdesc = new Dictionary<string, string>();
 | 
				
			||||||
 | 
					            foreach (Models.DocumentsTranslation item in questions)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                dicttitle.Add(item.Language, item.title);
 | 
				
			||||||
 | 
					                dictdesc.Add(item.Language, item.description);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            MultiLanguage.titles = dicttitle;
 | 
				
			||||||
 | 
					            MultiLanguage.description = dictdesc;
 | 
				
			||||||
 | 
					            return MultiLanguage;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanDocument> documents, string ErrorMessage)> GetdocumentsByLinkAsync(string? linkType, string? language)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                logger?.LogInformation("Query Question");
 | 
					                logger?.LogInformation("Query Question");
 | 
				
			||||||
                var documents=new List<Db.Document>();
 | 
					                var documents=new List<Db.Document>();
 | 
				
			||||||
                if(String.IsNullOrEmpty(LinkType))
 | 
					                if(String.IsNullOrEmpty(linkType))
 | 
				
			||||||
                    documents = await DocumentDbContext.Documents.AsNoTracking().Where(q => q.IsActive).ToListAsync();
 | 
					                    documents = await DocumentDbContext.Documents.Include(a=>a.LinkType).AsNoTracking().Where(q => q.IsActive).ToListAsync();
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                    documents = await DocumentDbContext.Documents.AsNoTracking().Where(q => q.IsActive &&
 | 
					                    documents = await DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().Where(q => q.IsActive &&
 | 
				
			||||||
                     q.linkTypeId == (DocumentDbContext.LinkTypes.AsNoTracking().Where(a => a.TypeText.ToLower() == LinkType.ToLower()).Select(a => a.Id).FirstOrDefault())).ToListAsync();
 | 
					                     q.linkTypeId == (DocumentDbContext.LinkTypes.AsNoTracking().Where(a => a.TypeText.ToLower() == linkType.ToLower()).Select(a => a.Id).FirstOrDefault())).ToListAsync();
 | 
				
			||||||
                if (documents != null)
 | 
					                if (documents != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var result = mapper.Map<IEnumerable<Db.Document>, IEnumerable<Models.Document>>(documents);
 | 
					                    var result = mapper.Map<List<Db.Document>, List<Models.MultiLanDocument>>(documents);
 | 
				
			||||||
                    foreach (var item in result)
 | 
					                    foreach (var item in result)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if(!String.IsNullOrEmpty(Language))
 | 
					                        var multilan = CreateMultiLanguageObject(GetDocumentTranslations(item.Id, language));
 | 
				
			||||||
                            item.documentsTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
					                        item.titles = multilan.titles;
 | 
				
			||||||
                                    DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == item.Id && (a.Language.ToLower() == Language.ToLower())).ToList());
 | 
					                        item.description = multilan.description;
 | 
				
			||||||
                        else
 | 
					 | 
				
			||||||
                        item.documentsTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
					 | 
				
			||||||
                                DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == item.Id).ToList());
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return (true, result, null);
 | 
					                    return (true, result, null);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -89,43 +116,44 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public async Task<(bool IsSuccess, IEnumerable<Models.Document> documents, string ErrorMessage)> GetDocumnetsAsync()
 | 
					        //public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanDocument> documents, string ErrorMessage)> GetDocumnetsAsync(string? language)
 | 
				
			||||||
        {
 | 
					        //{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try
 | 
					        //    try
 | 
				
			||||||
            {
 | 
					        //    {
 | 
				
			||||||
                logger?.LogInformation("Query Question");
 | 
					        //        logger?.LogInformation("Query Question");
 | 
				
			||||||
                var documents = await DocumentDbContext.Documents.AsNoTracking().Where(q => q.IsActive).ToListAsync();
 | 
					        //        var documents = await DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().Where(q => q.IsActive).ToListAsync();
 | 
				
			||||||
                if (documents != null)
 | 
					        //        if (documents != null)
 | 
				
			||||||
                {
 | 
					        //        {
 | 
				
			||||||
                    logger?.LogInformation($"{documents.Count} Document(s) found");
 | 
					        //            logger?.LogInformation($"{documents.Count} Document(s) found");
 | 
				
			||||||
                    var result = mapper.Map<IEnumerable<Db.Document>, IEnumerable<Models.Document>>(documents);
 | 
					        //            var result = mapper.Map<List<Db.Document>, List<Models.MultiLanDocument>>(documents);
 | 
				
			||||||
                    foreach (var item in result)
 | 
					        //            foreach (var item in result)
 | 
				
			||||||
                    {
 | 
					        //            {
 | 
				
			||||||
                        item.documentsTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
					        //                var multilan = CreateMultiLanguageObject(GetDocumentTranslations(item.Id, language));
 | 
				
			||||||
                                DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == item.Id).ToList());
 | 
					        //                item.titles = multilan.titles;
 | 
				
			||||||
                    }
 | 
					        //                item.description = multilan.description;
 | 
				
			||||||
                    return (true, result, null);
 | 
					        //            }
 | 
				
			||||||
                }
 | 
					        //            return (true, result, null);
 | 
				
			||||||
                return (false, null, "Not found");
 | 
					        //        }
 | 
				
			||||||
            }
 | 
					        //        return (false, null, "Not found");
 | 
				
			||||||
            catch (Exception ex)
 | 
					        //    }
 | 
				
			||||||
            {
 | 
					        //    catch (Exception ex)
 | 
				
			||||||
                logger?.LogError(ex.ToString());
 | 
					        //    {
 | 
				
			||||||
                return (false, null, ex.Message);
 | 
					        //        logger?.LogError(ex.ToString());
 | 
				
			||||||
            }
 | 
					        //        return (false, null, ex.Message);
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        //}
 | 
				
			||||||
        public async Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> GetDocumentAsync(int Id)
 | 
					        public async Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> GetDocumentByidAsync(int id)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                logger?.LogInformation("Query LinkType");
 | 
					                logger?.LogInformation("Query LinkType");
 | 
				
			||||||
                var Document = await DocumentDbContext.Documents.AsNoTracking().FirstOrDefaultAsync(q => q.Id == Id && q.IsActive);
 | 
					                var Document = await DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().FirstOrDefaultAsync(q => q.Id == id && q.IsActive);
 | 
				
			||||||
                if (Document != null)
 | 
					                if (Document != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    logger?.LogInformation($"{Document} customer(s) found");
 | 
					                    logger?.LogInformation($"{Document} customer(s) found");
 | 
				
			||||||
                    var result = mapper.Map<Db.Document, Models.Document>(Document);
 | 
					                    var result = mapper.Map<Db.Document, Models.Document>(Document); 
 | 
				
			||||||
                    result.documentsTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
					                    result.documentsTranslations = mapper.Map<List<Db.DocumentsTranslation>, List<Models.DocumentsTranslation>>(
 | 
				
			||||||
                            DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == result.Id).ToList());
 | 
					                            DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == result.Id).ToList());
 | 
				
			||||||
                    return (true, result, null);
 | 
					                    return (true, result, null);
 | 
				
			||||||
@ -138,7 +166,37 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
                return (false, null, ex.Message);
 | 
					                return (false, null, ex.Message);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public async Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> PostDocumentAsync(Models.Document Document)
 | 
					        //added linktype filter 
 | 
				
			||||||
 | 
					        public async Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> GetDocumentAsync(int id, string? linkType, string? language)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger?.LogInformation("Query LinkType");
 | 
				
			||||||
 | 
					                //var Document = await DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().FirstOrDefaultAsync(q => q.Id == id && q.IsActive);
 | 
				
			||||||
 | 
					                var Document = new Db.Document();
 | 
				
			||||||
 | 
					                if (String.IsNullOrEmpty(linkType))
 | 
				
			||||||
 | 
					                    Document = await DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().Where(q => q.IsActive&&q.Id==id).FirstOrDefaultAsync();
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    Document = await DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().Where(q => q.IsActive && q.Id == id &&
 | 
				
			||||||
 | 
					                     q.linkTypeId == (DocumentDbContext.LinkTypes.AsNoTracking().Where(a => a.TypeText.ToLower() == linkType.ToLower()).Select(a => a.Id).FirstOrDefault())).FirstOrDefaultAsync();
 | 
				
			||||||
 | 
					                if (Document != null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    logger?.LogInformation($"{Document} customer(s) found");
 | 
				
			||||||
 | 
					                    var result = mapper.Map<Db.Document, Models.MultiLanDocument>(Document);
 | 
				
			||||||
 | 
					                    var multilan = CreateMultiLanguageObject(GetDocumentTranslations(result.Id, language));
 | 
				
			||||||
 | 
					                    result.titles = multilan.titles;
 | 
				
			||||||
 | 
					                    result.description = multilan.description;
 | 
				
			||||||
 | 
					                    return (true, result, null);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return (false, null, "Not found");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                logger?.LogError(ex.ToString());
 | 
				
			||||||
 | 
					                return (false, null, ex.Message);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public async Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> PostDocumentAsync(Models.Document Document)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -149,8 +207,11 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
                dbtranslation.ForEach(i => i.DocumentId = document.Id);
 | 
					                dbtranslation.ForEach(i => i.DocumentId = document.Id);
 | 
				
			||||||
                DocumentDbContext.DocumentsTranslations.AddRange(dbtranslation);
 | 
					                DocumentDbContext.DocumentsTranslations.AddRange(dbtranslation);
 | 
				
			||||||
                DocumentDbContext.SaveChanges();
 | 
					                DocumentDbContext.SaveChanges();
 | 
				
			||||||
                Document.Id = document.Id;
 | 
					                var result = mapper.Map<Db.Document, Models.MultiLanDocument>(document);
 | 
				
			||||||
                return (true, Document, null);
 | 
					                var multilan = CreateMultiLanguageObject(GetDocumentTranslations(document.Id, ""));
 | 
				
			||||||
 | 
					                result.titles = multilan.titles;
 | 
				
			||||||
 | 
					                result.description = multilan.description;
 | 
				
			||||||
 | 
					                return (true, result, null);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception ex)
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -159,15 +220,16 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> UpdateDocumentAsync(Models.Document Document)
 | 
					        public async Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> UpdateDocumentAsync(int id,Models.Document Document)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (Document != null)
 | 
					                if (Document != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var existing = DocumentDbContext.Documents.AsNoTracking().FirstOrDefault(x => x.Id == Document.Id);
 | 
					                    var existing = DocumentDbContext.Documents.AsNoTracking().FirstOrDefault(x => x.Id == id);
 | 
				
			||||||
                    if (existing != null)
 | 
					                    if (existing != null)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
 | 
					                        Document.Id = existing.Id;
 | 
				
			||||||
                        var document = mapper.Map<Models.Document, Db.Document>(Document);
 | 
					                        var document = mapper.Map<Models.Document, Db.Document>(Document);
 | 
				
			||||||
                        DocumentDbContext.Documents.Update(document);
 | 
					                        DocumentDbContext.Documents.Update(document);
 | 
				
			||||||
                        DocumentDbContext.SaveChanges();
 | 
					                        DocumentDbContext.SaveChanges();
 | 
				
			||||||
@ -176,7 +238,13 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
                            DocumentDbContext.DocumentsTranslations.RemoveRange(oldtranslations);
 | 
					                            DocumentDbContext.DocumentsTranslations.RemoveRange(oldtranslations);
 | 
				
			||||||
                        var dbtranslation = mapper.Map<List<Models.DocumentsTranslation>, List<Db.DocumentsTranslation>>(Document.documentsTranslations);
 | 
					                        var dbtranslation = mapper.Map<List<Models.DocumentsTranslation>, List<Db.DocumentsTranslation>>(Document.documentsTranslations);
 | 
				
			||||||
                        dbtranslation.ForEach(i => i.DocumentId = Document.Id);
 | 
					                        dbtranslation.ForEach(i => i.DocumentId = Document.Id);
 | 
				
			||||||
                        return (true, Document, "Successful");
 | 
					                        DocumentDbContext.DocumentsTranslations.AddRange(dbtranslation);
 | 
				
			||||||
 | 
					                        DocumentDbContext.SaveChanges();
 | 
				
			||||||
 | 
					                        var result = mapper.Map<Db.Document, Models.MultiLanDocument>(document);
 | 
				
			||||||
 | 
					                        var multilan = CreateMultiLanguageObject(GetDocumentTranslations(document.Id, ""));
 | 
				
			||||||
 | 
					                        result.titles = multilan.titles;
 | 
				
			||||||
 | 
					                        result.description = multilan.description;
 | 
				
			||||||
 | 
					                        return (true, result, "Successful");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
@ -198,20 +266,24 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
                return (false, null, ex.Message);
 | 
					                return (false, null, ex.Message);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public async Task<(bool IsSuccess, Models.Document Document, string ErrorMessage)> DeleteDocumentAsync(int Id)
 | 
					        public async Task<(bool IsSuccess, Models.MultiLanDocument Document, string ErrorMessage)> DeleteDocumentAsync(int id)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Db.Document Document = DocumentDbContext.Documents.AsNoTracking().Where(a => a.Id == Id).FirstOrDefault();
 | 
					                Db.Document Document = DocumentDbContext.Documents.Include(a => a.LinkType).AsNoTracking().Where(a => a.Id == id).FirstOrDefault();
 | 
				
			||||||
                if (Document == null)
 | 
					                if (Document == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    return (false, null, "Not Found");
 | 
					                    return (false, null, "Not Found");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                var result = mapper.Map<Db.Document, Models.MultiLanDocument>(Document);
 | 
				
			||||||
 | 
					                var multilan = CreateMultiLanguageObject(GetDocumentTranslations(Document.Id, ""));
 | 
				
			||||||
 | 
					                result.titles = multilan.titles;
 | 
				
			||||||
 | 
					                result.description = multilan.description;
 | 
				
			||||||
                Document.IsActive = false;
 | 
					                Document.IsActive = false;
 | 
				
			||||||
                DocumentDbContext.Documents.Update(Document);
 | 
					                DocumentDbContext.Documents.Update(Document);
 | 
				
			||||||
                DocumentDbContext.SaveChanges();
 | 
					                DocumentDbContext.SaveChanges();
 | 
				
			||||||
                return (true, mapper.Map<Db.Document, Models.Document>(Document), $"DocumentId {Id} deleted Successfuly");
 | 
					                return (true, result, $"DocumentId {id} deleted Successfuly");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch (Exception ex)
 | 
					            catch (Exception ex)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -257,7 +329,6 @@ namespace DamageAssesment.Api.Documents.Providers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async Task<(bool IsSuccess, Models.LinkType LinkType, string ErrorMessage)> GetLinkTypeAsync(int Id)
 | 
					        public async Task<(bool IsSuccess, Models.LinkType LinkType, string ErrorMessage)> GetLinkTypeAsync(int Id)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
 | 
				
			|||||||
@ -37,9 +37,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Employe
 | 
				
			|||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Employees.Test", "DamageAssesment.Api.Employees.Test\DamageAssesment.Api.Employees.Test.csproj", "{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}"
 | 
					Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Employees.Test", "DamageAssesment.Api.Employees.Test\DamageAssesment.Api.Employees.Test.csproj", "{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}"
 | 
				
			||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DamageAssesment.Api.Documents", "DamageAssesment.Api.Documents\DamageAssesment.Api.Documents.csproj", "{977C1053-9D63-4153-B61B-C3D2F1010F9F}"
 | 
					Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.DocuLinks", "DamageAssesment.Api.Documents\DamageAssesment.Api.DocuLinks.csproj", "{977C1053-9D63-4153-B61B-C3D2F1010F9F}"
 | 
				
			||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DamageAssesment.Api.Documents.Test", "DamageAssesment.Api.Documents.Test\DamageAssesment.Api.Documents.Test.csproj", "{884BA4AC-9170-49B1-BD6B-850B350C95C0}"
 | 
					Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.DocuLinks.Test", "DamageAssesment.Api.Documents.Test\DamageAssesment.Api.DocuLinks.Test.csproj", "{884BA4AC-9170-49B1-BD6B-850B350C95C0}"
 | 
				
			||||||
EndProject
 | 
					EndProject
 | 
				
			||||||
Global
 | 
					Global
 | 
				
			||||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
						GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user