Update survey response, adding EmployeeId , Location Id as int, adjust end point for ansers submission in batch

This commit is contained in:
Reginald Cherenfant Jasmin
2023-09-13 01:28:24 -04:00
parent 4cf7d9f891
commit 9109d0d793
68 changed files with 525 additions and 540 deletions

View File

@ -7,14 +7,13 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
public class AnswerServiceProvider : ServiceProviderBase, IAnswerServiceProvider
{
public AnswerServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<AnswerServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Answers", configuration.GetValue<string>("EndPointSettings:AnswerUrlBase"))
public AnswerServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<AnswerServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Answer"), configuration.GetValue<string>("EndPointSettings:AnswerUrlBase"))
{
}
public async Task<List<Answer>> getAnswersAsync()
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var answers = JsonConvert.DeserializeObject<List<Answer>>(responseJsonString);
@ -33,7 +32,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + "/api/AnswersByResponse/" + responseId;
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:AnswerByResponse"), responseId);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var answers = JsonConvert.DeserializeObject<List<Answer>>(responseJsonString);
@ -52,7 +51,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var requestJsonString = JsonConvert.SerializeObject(answer);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Post, url, requestJsonString);
var answers = JsonConvert.DeserializeObject<Answer>(responseJsonString);

View File

@ -6,7 +6,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
public class AttachmentServiceProvider : ServiceProviderBase, IAttachmentServiceProvider
{
public AttachmentServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<AttachmentServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Attachments", configuration.GetValue<string>("EndPointSettings:AttachmentUrlBase"))
public AttachmentServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<AttachmentServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Attachment"), configuration.GetValue<string>("EndPointSettings:AttachmentUrlBase"))
{
}
@ -14,7 +14,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var attachments = JsonConvert.DeserializeObject<List<Attachment>>(responseJsonString);
@ -33,7 +32,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var requestJsonString = JsonConvert.SerializeObject(attachmentInfo);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Post, url, requestJsonString);
var attachments = JsonConvert.DeserializeObject<IEnumerable<Attachment>>(responseJsonString);

View File

@ -1,12 +1,13 @@
using DamageAssesment.Api.SurveyResponses.Interfaces;
using DamageAssesment.Api.SurveyResponses.Models;
using Microsoft.AspNetCore.Mvc.Routing;
using Newtonsoft.Json;
namespace DamageAssesment.Api.SurveyResponses.Services
{
public class EmployeeServiceProvider :ServiceProviderBase, IEmployeeServiceProvider
public class EmployeeServiceProvider : ServiceProviderBase, IEmployeeServiceProvider
{
public EmployeeServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Employees", configuration.GetValue<string>("EndPointSettings:EmployeeUrlBase"))
public EmployeeServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Employee"), configuration.GetValue<string>("EndPointSettings:EmployeeUrlBase"))
{
}
@ -14,7 +15,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var employees = JsonConvert.DeserializeObject<List<Employee>>(responseJsonString);
@ -29,15 +29,15 @@ namespace DamageAssesment.Api.SurveyResponses.Services
}
}
public async Task<Employee> getEmployeeAsync(string employeeId)
public async Task<Employee> getEmployeeAsync(int employeeId)
{
try
{
var url = urlBase + "/api/Employees/" + employeeId;
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:EmployeeById"), employeeId);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var employee = JsonConvert.DeserializeObject<Employee>(responseJsonString);
if (employee == null )
if (employee == null)
return null;
else return employee;
}

View File

@ -6,7 +6,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider
{
public LocationServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<LocationServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Locations", configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
public LocationServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<LocationServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Location"), configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
{
}
@ -14,7 +14,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var locations = JsonConvert.DeserializeObject<List<Location>>(responseJsonString);

View File

@ -6,7 +6,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
public class QuestionServiceProvider : ServiceProviderBase, IQuestionServiceProvider
{
public QuestionServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<QuestionServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Questions", configuration.GetValue<string>("EndPointSettings:QuestionUrlBase"))
public QuestionServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<QuestionServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Question"), configuration.GetValue<string>("EndPointSettings:QuestionUrlBase"))
{
}
@ -14,7 +14,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var questions = JsonConvert.DeserializeObject<List<Question>>(responseJsonString);
@ -33,7 +32,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + "/api/GetSurveyQuestions/" + surveyId;
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:SurveyQuestion"), surveyId);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var questions = JsonConvert.DeserializeObject<List<SurveyQuestions>>(responseJsonString);
@ -53,7 +52,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + "/api/Questions/" + questionId;
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:QuestionById"), questionId);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var question = JsonConvert.DeserializeObject<Question>(responseJsonString);

View File

@ -6,14 +6,13 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
public class RegionServiceProvider : ServiceProviderBase, IRegionServiceProvider
{
public RegionServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<RegionServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Regions", configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
public RegionServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<RegionServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Region"), configuration.GetValue<string>("EndPointSettings:LocationUrlBase"))
{
}
public async Task<List<Region>> getRegionsAsync()
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var regions = JsonConvert.DeserializeObject<List<Region>>(responseJsonString);

View File

@ -9,6 +9,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
protected readonly ILogger<ServiceProviderBase> logger;
protected string ressource;
protected string urlBase;
protected string url;
public ServiceProviderBase(IConfiguration configuration, IHttpUtil httpUtil, ILogger<ServiceProviderBase> logger, string ressource, string urlBase)
@ -18,6 +19,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
this.logger = logger;
this.ressource = ressource;
this.urlBase = urlBase;
url = urlBase + ressource;
}
}
}

View File

@ -6,7 +6,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider
{
public SurveyServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpUtil, logger, "/api/Surveys", configuration.GetValue<string>("EndPointSettings:SurveyUrlBase"))
public SurveyServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Survey"), configuration.GetValue<string>("EndPointSettings:SurveyUrlBase"))
{
}
@ -14,8 +14,6 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource;
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var surveys = JsonConvert.DeserializeObject<List<Survey>>(responseJsonString);
@ -34,7 +32,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
{
try
{
var url = urlBase + ressource + "/" + surveyId;
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:SurveyById"), surveyId);
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
var survey = JsonConvert.DeserializeObject<Survey>(responseJsonString);