From cf3a04891b7b50d0a02ac9c8b9a78ccb9436c35c Mon Sep 17 00:00:00 2001 From: uppuv Date: Fri, 25 Aug 2023 07:20:37 -0400 Subject: [PATCH] Completed sync call for answer and attachment put and post methods --- .../Controllers/AnswersController.cs | 8 ++++---- .../Interfaces/IAnswersProvider.cs | 4 ++-- .../Providers/AnswerProvider.cs | 4 ++-- .../Controllers/AttachmentsController.cs | 12 ++++++------ .../Interfaces/IAttachmentsProvider.cs | 8 ++++---- .../Providers/AttachmentsProvider.cs | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs index a8fefff..95b2aab 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Controllers/AnswersController.cs @@ -78,11 +78,11 @@ namespace DamageAssesment.Api.Answers.Controllers /// [HttpPut("Answers")] - public async Task UpdateAnswer(Db.Answer answer) + public IActionResult UpdateAnswer(Db.Answer answer) { if (answer != null) { - var result = await this.answerProvider.UpdateAnswerAsync(answer); + var result = this.answerProvider.UpdateAnswerAsync(answer); if (result.IsSuccess) { return Ok(result.Answer); @@ -99,11 +99,11 @@ namespace DamageAssesment.Api.Answers.Controllers /// [HttpPost("Answers")] - public async Task CreateAnswer(Db.Answer answer) + public IActionResult CreateAnswer(Db.Answer answer) { if (answer != null) { - var result = await this.answerProvider.PostAnswerAsync(answer); + var result = this.answerProvider.PostAnswerAsync(answer); if (result.IsSuccess) { return Ok(result.Answer); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs index 4a202f1..4b5fcc1 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Interfaces/IAnswersProvider.cs @@ -6,8 +6,8 @@ Task<(bool IsSuccess, IEnumerable Answers, string ErrorMessage)> GetAnswersByQuestionAsync(int questionId); Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> GetAnswerByIdAsync(int Id); Task<(bool IsSuccess, IEnumerable Answers, string ErrorMessage)> GetAnswersAsync(int responseId); - Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Db.Answer Answer); - Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> UpdateAnswerAsync(Db.Answer Answer); + (bool IsSuccess, Models.Answer Answer, string ErrorMessage) PostAnswerAsync(Db.Answer Answer); + (bool IsSuccess, Models.Answer Answer, string ErrorMessage) UpdateAnswerAsync(Db.Answer Answer); Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs index b1851d8..f7f2268 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Answers/Providers/AnswerProvider.cs @@ -108,7 +108,7 @@ namespace DamageAssesment.Api.Answers.Providers return (false, null, ex.Message); } } - public async Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Db.Answer Answer) + public (bool IsSuccess, Models.Answer Answer, string ErrorMessage) PostAnswerAsync(Db.Answer Answer) { try { @@ -128,7 +128,7 @@ namespace DamageAssesment.Api.Answers.Providers return (false, null, ex.Message); } } - public async Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> UpdateAnswerAsync(Db.Answer Answer) + public (bool IsSuccess, Models.Answer Answer, string ErrorMessage) UpdateAnswerAsync(Db.Answer Answer) { try { diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs index 11cec22..745db41 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Controllers/AttachmentsController.cs @@ -83,15 +83,15 @@ namespace DamageAssesment.Api.Attachments.Controllers /// [HttpPost("Attachments"), DisableRequestSizeLimit] - public async Task UploadAttachmentAsync(AttachmentInfo attachmentInfo) + public IActionResult UploadAttachmentAsync(AttachmentInfo attachmentInfo) { try { if (attachmentInfo.Answers.Count > 0) { - var Attachments = await this.AttachmentProvider.GetAttachmentCounter(); + var Attachments = this.AttachmentProvider.GetAttachmentCounter(); List attachments = UploadService.UploadAttachment(attachmentInfo.ResponseId, Attachments.counter, attachmentInfo.Answers); - var result = await this.AttachmentProvider.PostAttachmentAsync(attachments); + var result = this.AttachmentProvider.PostAttachmentAsync(attachments); if (result.IsSuccess) { return Ok(result.Attachments); @@ -110,17 +110,17 @@ namespace DamageAssesment.Api.Attachments.Controllers /// [HttpPut("Attachments"), DisableRequestSizeLimit] - public async Task UpdateAttachmentAsync(AttachmentInfo attachmentInfo) + public IActionResult UpdateAttachmentAsync(AttachmentInfo attachmentInfo) { try { if (attachmentInfo.Answers.Count > 0) { - var res = await this.AttachmentProvider.GetAttachmentInfo(attachmentInfo.Answers); + var res = this.AttachmentProvider.GetAttachmentInfo(attachmentInfo.Answers); if (res.IsSuccess) { List attachments = UploadService.UpdateAttachments(attachmentInfo.ResponseId, attachmentInfo.Answers, res.Attachments); - var result = await this.AttachmentProvider.PutAttachmentAsync(attachments); + var result = this.AttachmentProvider.PutAttachmentAsync(attachments); if (result.IsSuccess) { return Ok(result.Attachments); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs index f193e11..81bc749 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Interfaces/IAttachmentsProvider.cs @@ -6,12 +6,12 @@ namespace DamageAssesment.Api.Attachments.Interfaces { Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> GetAttachmentsAsync(); Task<(bool IsSuccess, Models.Attachment Attachment, string ErrorMessage)> GetAttachmentByIdAsync(int Id); - Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PostAttachmentAsync(List Attachments); - Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PutAttachmentAsync(List Attachments); + (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PostAttachmentAsync(List Attachments); + (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PutAttachmentAsync(List Attachments); Task<(bool IsSuccess, Models.Attachment Attachment, string Path)> DeleteAttachmentAsync(int Id); Task<(bool IsSuccess, int counter, string Path)> DeleteAttachmentsAsync(int responseId, int answerId); Task<(bool IsSuccess, int counter, string Path)> DeleteBulkAttachmentsAsync(int responseId, List answerIds); - Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter(); - Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> GetAttachmentInfo(List answers); + (bool IsSuccess, int counter, string message) GetAttachmentCounter(); + (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) GetAttachmentInfo(List answers); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs index 6a3cc63..aa42d93 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Attachments/Providers/AttachmentsProvider.cs @@ -65,7 +65,7 @@ namespace DamageAssesment.Api.Attachments.Providers return (false, null, ex.Message); } } - public async Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PostAttachmentAsync(List Attachments) + public (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PostAttachmentAsync(List Attachments) { try { @@ -82,7 +82,7 @@ namespace DamageAssesment.Api.Attachments.Providers } } - public async Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)> PutAttachmentAsync(List Attachments) + public (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) PutAttachmentAsync(List Attachments) { try { @@ -119,7 +119,7 @@ namespace DamageAssesment.Api.Attachments.Providers return (false, AttachmentId, ""); } } - public async Task<(bool IsSuccess,int counter,string message)> GetAttachmentCounter() + public (bool IsSuccess,int counter,string message) GetAttachmentCounter() { try { @@ -152,7 +152,7 @@ namespace DamageAssesment.Api.Attachments.Providers return (false, AttachmentId, ""); } } - public async Task<(bool IsSuccess, IEnumerable Attachments, string ErrorMessage)>GetAttachmentInfo(List answers) + public (bool IsSuccess, IEnumerable Attachments, string ErrorMessage) GetAttachmentInfo(List answers) { try {