Completed sync call for answer and attachment put and post methods
This commit is contained in:
parent
e56ffae1a4
commit
cf3a04891b
@ -78,11 +78,11 @@ namespace DamageAssesment.Api.Answers.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut("Answers")]
|
[HttpPut("Answers")]
|
||||||
public async Task<IActionResult> UpdateAnswer(Db.Answer answer)
|
public IActionResult UpdateAnswer(Db.Answer answer)
|
||||||
{
|
{
|
||||||
if (answer != null)
|
if (answer != null)
|
||||||
{
|
{
|
||||||
var result = await this.answerProvider.UpdateAnswerAsync(answer);
|
var result = this.answerProvider.UpdateAnswerAsync(answer);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Answer);
|
return Ok(result.Answer);
|
||||||
@ -99,11 +99,11 @@ namespace DamageAssesment.Api.Answers.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("Answers")]
|
[HttpPost("Answers")]
|
||||||
public async Task<IActionResult> CreateAnswer(Db.Answer answer)
|
public IActionResult CreateAnswer(Db.Answer answer)
|
||||||
{
|
{
|
||||||
if (answer != null)
|
if (answer != null)
|
||||||
{
|
{
|
||||||
var result = await this.answerProvider.PostAnswerAsync(answer);
|
var result = this.answerProvider.PostAnswerAsync(answer);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Answer);
|
return Ok(result.Answer);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersByQuestionAsync(int questionId);
|
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, Models.Answer Answer, string ErrorMessage)> GetAnswerByIdAsync(int Id);
|
||||||
Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersAsync(int responseId);
|
Task<(bool IsSuccess, IEnumerable<Models.Answer> Answers, string ErrorMessage)> GetAnswersAsync(int responseId);
|
||||||
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> PostAnswerAsync(Db.Answer Answer);
|
(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) UpdateAnswerAsync(Db.Answer Answer);
|
||||||
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id);
|
Task<(bool IsSuccess, Models.Answer Answer, string ErrorMessage)> DeleteAnswerAsync(int Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ namespace DamageAssesment.Api.Answers.Providers
|
|||||||
return (false, null, ex.Message);
|
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
|
try
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ namespace DamageAssesment.Api.Answers.Providers
|
|||||||
return (false, null, ex.Message);
|
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
|
try
|
||||||
{
|
{
|
||||||
|
@ -83,15 +83,15 @@ namespace DamageAssesment.Api.Attachments.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("Attachments"), DisableRequestSizeLimit]
|
[HttpPost("Attachments"), DisableRequestSizeLimit]
|
||||||
public async Task<IActionResult> UploadAttachmentAsync(AttachmentInfo attachmentInfo)
|
public IActionResult UploadAttachmentAsync(AttachmentInfo attachmentInfo)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (attachmentInfo.Answers.Count > 0)
|
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);
|
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)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Attachments);
|
return Ok(result.Attachments);
|
||||||
@ -110,17 +110,17 @@ namespace DamageAssesment.Api.Attachments.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut("Attachments"), DisableRequestSizeLimit]
|
[HttpPut("Attachments"), DisableRequestSizeLimit]
|
||||||
public async Task<IActionResult> UpdateAttachmentAsync(AttachmentInfo attachmentInfo)
|
public IActionResult UpdateAttachmentAsync(AttachmentInfo attachmentInfo)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (attachmentInfo.Answers.Count > 0)
|
if (attachmentInfo.Answers.Count > 0)
|
||||||
{
|
{
|
||||||
var res = await this.AttachmentProvider.GetAttachmentInfo(attachmentInfo.Answers);
|
var res = this.AttachmentProvider.GetAttachmentInfo(attachmentInfo.Answers);
|
||||||
if (res.IsSuccess)
|
if (res.IsSuccess)
|
||||||
{
|
{
|
||||||
List<Db.Attachment> attachments = UploadService.UpdateAttachments(attachmentInfo.ResponseId, attachmentInfo.Answers, res.Attachments);
|
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)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Attachments);
|
return Ok(result.Attachments);
|
||||||
|
@ -6,12 +6,12 @@ namespace DamageAssesment.Api.Attachments.Interfaces
|
|||||||
{
|
{
|
||||||
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync();
|
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync();
|
||||||
Task<(bool IsSuccess, Models.Attachment Attachment, string ErrorMessage)> GetAttachmentByIdAsync(int Id);
|
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);
|
(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) PutAttachmentAsync(List<Db.Attachment> Attachments);
|
||||||
Task<(bool IsSuccess, Models.Attachment Attachment, string Path)> DeleteAttachmentAsync(int Id);
|
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)> DeleteAttachmentsAsync(int responseId, int answerId);
|
||||||
Task<(bool IsSuccess, int counter, string Path)> DeleteBulkAttachmentsAsync(int responseId, List<int> answerIds);
|
Task<(bool IsSuccess, int counter, string Path)> DeleteBulkAttachmentsAsync(int responseId, List<int> answerIds);
|
||||||
Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter();
|
(bool IsSuccess, int counter, string message) GetAttachmentCounter();
|
||||||
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentInfo(List<AnswerInfo> answers);
|
(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage) GetAttachmentInfo(List<AnswerInfo> answers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace DamageAssesment.Api.Attachments.Providers
|
|||||||
return (false, null, ex.Message);
|
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
|
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
|
try
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ namespace DamageAssesment.Api.Attachments.Providers
|
|||||||
return (false, AttachmentId, "");
|
return (false, AttachmentId, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess,int counter,string message)> GetAttachmentCounter()
|
public (bool IsSuccess,int counter,string message) GetAttachmentCounter()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -152,7 +152,7 @@ namespace DamageAssesment.Api.Attachments.Providers
|
|||||||
return (false, AttachmentId, "");
|
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
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user