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

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