Completed sync call for answer and attachment put and post methods

This commit is contained in:
uppuv 2023-08-25 07:20:37 -04:00
parent e56ffae1a4
commit cf3a04891b
6 changed files with 22 additions and 22 deletions

View File

@ -78,11 +78,11 @@ namespace DamageAssesment.Api.Answers.Controllers
/// </summary>
[HttpPut("Answers")]
public async Task<IActionResult> 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
/// </summary>
[HttpPost("Answers")]
public async Task<IActionResult> 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);

View File

@ -6,8 +6,8 @@
Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersByQuestionAsync(int questionId);
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> GetAnswerByIdAsync(int Id);
Task<(bool IsSuccess, IEnumerable<Models.Answer> 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);
}
}

View File

@ -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
{

View File

@ -83,15 +83,15 @@ namespace DamageAssesment.Api.Attachments.Controllers
/// </summary>
[HttpPost("Attachments"), DisableRequestSizeLimit]
public async Task<IActionResult> 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<Db.Attachment> 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
/// </summary>
[HttpPut("Attachments"), DisableRequestSizeLimit]
public async Task<IActionResult> 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<Db.Attachment> 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);

View File

@ -6,12 +6,12 @@ namespace DamageAssesment.Api.Attachments.Interfaces
{
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync();
Task<(bool IsSuccess, Models.Attachment Attachment, string ErrorMessage)> GetAttachmentByIdAsync(int Id);
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PostAttachmentAsync(List<Db.Attachment> Attachments);
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PutAttachmentAsync(List<Db.Attachment> Attachments);
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PostAttachmentAsync(List<Db.Attachment> Attachments);
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PutAttachmentAsync(List<Db.Attachment> 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<int> answerIds);
Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter();
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentInfo(List<AnswerInfo> answers);
(bool IsSuccess, int counter, string message) GetAttachmentCounter();
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) GetAttachmentInfo(List<AnswerInfo> answers);
}
}

View File

@ -65,7 +65,7 @@ namespace DamageAssesment.Api.Attachments.Providers
return (false, null, ex.Message);
}
}
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PostAttachmentAsync(List<Db.Attachment> Attachments)
public (bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PostAttachmentAsync(List<Db.Attachment> Attachments)
{
try
{
@ -82,7 +82,7 @@ namespace DamageAssesment.Api.Attachments.Providers
}
}
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> PutAttachmentAsync(List<Db.Attachment> Attachments)
public (bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) PutAttachmentAsync(List<Db.Attachment> 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<Models.Attachment> Attachments, string ErrorMessage)>GetAttachmentInfo(List<AnswerInfo> answers)
public (bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) GetAttachmentInfo(List<AnswerInfo> answers)
{
try
{