Add EmployeeId as filter in the endpoints, add endpoints to get all active and historical surveys for a particular employee
This commit is contained in:
parent
8d386af40a
commit
a0033ca045
@ -1,8 +1,6 @@
|
|||||||
using DamageAssesment.Api.SurveyResponses.Interfaces;
|
using DamageAssesment.Api.SurveyResponses.Interfaces;
|
||||||
using DamageAssesment.Api.SurveyResponses.Models;
|
using DamageAssesment.Api.SurveyResponses.Models;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||||
{
|
{
|
||||||
@ -19,10 +17,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// GET request for retrieving survey responses.
|
/// GET request for retrieving survey responses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("Responses")]
|
[Route("Responses/{employeeid:int}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesAsync()
|
[Route("Responses")]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetSurveyResponsesAsync(int? employeeid)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesAsync();
|
var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(employeeid ?? 0);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.surveyResponses);
|
return Ok(result.surveyResponses);
|
||||||
@ -36,11 +36,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET request for retrieving survey responses by survey ID.
|
/// GET request for retrieving survey responses by survey ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Route("Responses/BySurvey/{surveyid:int}/{employeeid:int}")]
|
||||||
[HttpGet("Responses/BySurvey/{surveyid}")]
|
[Route("Responses/BySurvey/{surveyid:int}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyid)
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyid, int? employeeid)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid, employeeid ?? 0);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.SurveyResponses);
|
return Ok(result.SurveyResponses);
|
||||||
@ -53,15 +54,16 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="surveyid">The ID of the survey for which responses are to be retrieved.</param>
|
/// <param name="surveyid">The ID of the survey for which responses are to be retrieved.</param>
|
||||||
/// <param name="locationid">The ID of the location for which responses are to be retrieved.</param>
|
/// <param name="locationid">The ID of the location for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("Responses/{surveyid}/{locationid}")]
|
[Route("Responses/{surveyid:int}/{locationid:int}/{employeeid:int}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyid, int locationid)
|
[Route("Responses/{surveyid:int}/{locationid:int}")]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyid, int locationid,int? employeeid)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyid, locationid);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyid, locationid,employeeid ?? 0);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.SurveyResponses);
|
return Ok(result.SurveyResponses);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -71,10 +73,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
||||||
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("Responses/ByAnswer/{surveyid}/{questionid}/{answer}")]
|
[Route("Responses/ByAnswer/{surveyid:int}/{questionid:int}/{answer:alpha}/{employeeid:int}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer)
|
[Route("Responses/ByAnswer/{surveyid:int}/{questionid:int}/{answer:alpha}")]
|
||||||
{
|
[HttpGet]
|
||||||
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer);
|
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer, int? employeeid)
|
||||||
|
{
|
||||||
|
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer, employeeid ?? 0);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.SurveyResponses);
|
return Ok(result.SurveyResponses);
|
||||||
@ -87,10 +91,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("Responses/ByRegion/{surveyid}")]
|
[Route("Responses/ByRegion/{surveyid:int}")]
|
||||||
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyid)
|
[Route("Responses/ByRegion/{surveyid:int}/{employeeid}")]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyid, int? employeeid)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid);
|
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid, employeeid ?? 0);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Answers);
|
return Ok(result.Answers);
|
||||||
@ -101,11 +107,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// GET request for retrieving survey responses by survey ID and maintenance center.
|
/// GET request for retrieving survey responses by survey ID and maintenance center.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
||||||
|
[Route("Responses/ByMaintenanceCenter/{surveyid:int}/{employeeid:int}")]
|
||||||
[HttpGet("Responses/ByMaintenanceCenter/{surveyid}")]
|
[Route("Responses/ByMaintenanceCenter/{surveyid:int}")]
|
||||||
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyid)
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyid, int? employeeid)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid, employeeid ?? 0);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.SurveyResponses);
|
return Ok(result.SurveyResponses);
|
||||||
@ -165,7 +172,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// DELETE request for deleting an existing survey response.
|
/// DELETE request for deleting an existing survey response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpDelete("Responses/{id}")]
|
[HttpDelete("Responses/{id}")]
|
||||||
public async Task<ActionResult> DeleteSurveyResponseAsync(int id)
|
public async Task<ActionResult> DeleteSurveyResponseAsync(int id)
|
||||||
{
|
{
|
||||||
@ -191,5 +198,31 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
else
|
else
|
||||||
return BadRequest(result.ErrorMessage);
|
return BadRequest(result.ErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("Responses/Surveys/active/{employeeid:int}")]
|
||||||
|
[Route("Responses/Surveys/active/{employeeid:int}/{language:alpha}")]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetActiveSurveysAsync(int employeeid, string? language)
|
||||||
|
{
|
||||||
|
var result = await this.surveyResponseProvider.GetActiveSurveysAsync(employeeid, language);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Ok(result.Surveys);
|
||||||
|
}
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("Responses/Surveys/historic/{employeeid:int}")]
|
||||||
|
[Route("Responses/Surveys/historic/{employeeid:int}/{language:alpha}")]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult> GetHistoricSurveysAsync(int employeeid, string? language)
|
||||||
|
{
|
||||||
|
var result = await this.surveyResponseProvider.GetHistoricSurveysAsync(employeeid, language);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
return Ok(result.Surveys);
|
||||||
|
}
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace DamageAssesment.Api.SurveyResponses.Interfaces
|
|||||||
{
|
{
|
||||||
public interface ISurveyServiceProvider
|
public interface ISurveyServiceProvider
|
||||||
{
|
{
|
||||||
Task<List<Survey>> getSurveysAsync();
|
Task<List<Survey>> getSurveysAsync(string language);
|
||||||
Task<Survey> getSurveyAsync(int surveyId);
|
Task<Survey> getSurveyAsync(int surveyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,19 @@ namespace DamageAssesment.Api.SurveyResponses.Interfaces
|
|||||||
{
|
{
|
||||||
public interface ISurveysResponse
|
public interface ISurveysResponse
|
||||||
{
|
{
|
||||||
Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId);
|
Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId, int employeeid);
|
||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyResponseAsync(Models.SurveyResponse surveyResponse);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyResponseAsync(Models.SurveyResponse surveyResponse);
|
||||||
// Task<(bool IsSuccess,dynamic surveyResponses, string ErrorMessage)> GetSurveyResponseAsync(int responseId);
|
// Task<(bool IsSuccess,dynamic surveyResponses, string ErrorMessage)> GetSurveyResponseAsync(int responseId);
|
||||||
Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync();
|
Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync(int employeeid);
|
||||||
|
Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetActiveSurveysAsync(int employeeid, string language);
|
||||||
|
Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetHistoricSurveysAsync(int employeeid, string language);
|
||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse);
|
||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> DeleteSurveyResponseAsync(int Id);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> DeleteSurveyResponseAsync(int Id);
|
||||||
Task<(bool IsSuccess, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId);
|
Task<(bool IsSuccess, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId);
|
||||||
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId);
|
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId, int employeeid);
|
||||||
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId);
|
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId, int employeeid);
|
||||||
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId);
|
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId, int employeeid);
|
||||||
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer);
|
Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer, int employeeid);
|
||||||
|
|
||||||
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Request request);
|
Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Request request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
this.questionServiceProvider = questionServiceProvider;
|
this.questionServiceProvider = questionServiceProvider;
|
||||||
this.surveyServiceProvider = surveyServiceProvider;
|
this.surveyServiceProvider = surveyServiceProvider;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
// seedData();
|
// seedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seedData()
|
private void seedData()
|
||||||
@ -48,12 +48,20 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId)
|
public async Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
||||||
var listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId);
|
IQueryable<Db.SurveyResponse> listSurveyResponse = null;
|
||||||
|
if (employeeid == 0)
|
||||||
|
{
|
||||||
|
listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId && s.EmployeeId == employeeid);
|
||||||
|
}
|
||||||
|
|
||||||
if (listSurveyResponse.Any())
|
if (listSurveyResponse.Any())
|
||||||
{
|
{
|
||||||
@ -102,10 +110,58 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetActiveSurveysAsync(int employeeid, string language)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
||||||
|
//get all the survey that already taken by the employee
|
||||||
|
var listOfsurveysId = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).Select(y => y.SurveyId).ToListAsync();
|
||||||
|
var surveys = await surveyServiceProvider.getSurveysAsync(language);
|
||||||
|
|
||||||
|
if (surveys != null)
|
||||||
|
{
|
||||||
|
surveys = surveys.Where(s => s.IsEnabled == true && s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listOfsurveysId==null || listOfsurveysId.Count == 0)
|
||||||
|
return (true, surveys, null);
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId)
|
var activeSurveys = surveys.Where(s => s.IsEnabled == true && s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now && !listOfsurveysId.Contains(s.Id));
|
||||||
|
return (true, activeSurveys, null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger?.LogError(ex.ToString());
|
||||||
|
return (false, null, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(bool IsSuccess, dynamic Surveys, string ErrorMessage)> GetHistoricSurveysAsync(int employeeid, string language)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
logger?.LogInformation("Querying to get SurveyResponse object from DB");
|
||||||
|
//get all the survey that already taken by the employee
|
||||||
|
var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).ToListAsync();
|
||||||
|
var surveys = await surveyServiceProvider.getSurveysAsync(language);
|
||||||
|
|
||||||
|
var historicSurveys = from s in surveys
|
||||||
|
from r in surveyResponses
|
||||||
|
where s.Id == r.SurveyId
|
||||||
|
select s;
|
||||||
|
|
||||||
|
return (true, historicSurveys, null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger?.LogError(ex.ToString());
|
||||||
|
return (false, null, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -114,7 +170,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
if (survey != null)
|
if (survey != null)
|
||||||
{
|
{
|
||||||
var answers = await getSurveyResponsesBySurveyIdAsync(surveyId);
|
var answers = await getSurveyResponsesBySurveyIdAsync(surveyId, employeeid);
|
||||||
|
|
||||||
if (answers != null)
|
if (answers != null)
|
||||||
return (true, answers, "Request Successful.");
|
return (true, answers, "Request Successful.");
|
||||||
@ -136,7 +192,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId)
|
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -145,7 +201,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
if (survey != null)
|
if (survey != null)
|
||||||
{
|
{
|
||||||
var answers = await getSurveyResponsesBySurveyIdLocationIdAsync(surveyId, locationId);
|
var answers = await getSurveyResponsesBySurveyIdLocationIdAsync(surveyId, locationId, employeeid);
|
||||||
|
|
||||||
if (answers != null)
|
if (answers != null)
|
||||||
return (true, answers, "Request Successful.");
|
return (true, answers, "Request Successful.");
|
||||||
@ -167,7 +223,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId)
|
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -176,7 +232,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
if (survey != null)
|
if (survey != null)
|
||||||
{
|
{
|
||||||
var answers = await getResultsByMaintenanceCenterAsync(surveyId);
|
var answers = await getResultsByMaintenanceCenterAsync(surveyId, employeeid);
|
||||||
|
|
||||||
if (answers != null)
|
if (answers != null)
|
||||||
return (true, answers, "Request Successful.");
|
return (true, answers, "Request Successful.");
|
||||||
@ -198,7 +254,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer)
|
public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -210,7 +266,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
if (survey != null && question != null && IsCorrectAnswer)
|
if (survey != null && question != null && IsCorrectAnswer)
|
||||||
{
|
{
|
||||||
var answers = await getSurveyResponsesByAnswerAsync(survey, question, answer);
|
var answers = await getSurveyResponsesByAnswerAsync(survey, question, answer, employeeid);
|
||||||
|
|
||||||
if (answers != null)
|
if (answers != null)
|
||||||
return (true, answers, "Request Successful.");
|
return (true, answers, "Request Successful.");
|
||||||
@ -233,18 +289,18 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync()
|
public async Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync(int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var answers = await getAllSurveyResponsesAsync();
|
var responses = await getAllSurveyResponsesAsync(employeeid);
|
||||||
|
|
||||||
if (answers != null)
|
if (responses != null)
|
||||||
return (true, answers, "Request Successful.");
|
return (true, responses, "Request Successful.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
answers = new List<Models.SurveyResponse>();
|
responses = new List<Models.SurveyResponse>();
|
||||||
return (true, answers, "Empty object returned");
|
return (true, responses, "Empty object returned");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -355,7 +411,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
answer => answer.SurveyResponseId,
|
answer => answer.SurveyResponseId,
|
||||||
surveyResponse => surveyResponse.Id,
|
surveyResponse => surveyResponse.Id,
|
||||||
(answer, surveyResponse) => new
|
(answer, surveyResponse) => new
|
||||||
|
|
||||||
{
|
{
|
||||||
answer.Id,
|
answer.Id,
|
||||||
answer.QuestionId,
|
answer.QuestionId,
|
||||||
@ -379,18 +435,18 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
var result = from answer in surveyAnswers
|
var result = from answer in surveyAnswers
|
||||||
from location in locations
|
from location in locations
|
||||||
where answer.LocationId.Equals(location.Id)
|
where answer.LocationId.Equals(location.Id)
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
answer.Id,
|
answer.Id,
|
||||||
answer.QuestionId,
|
answer.QuestionId,
|
||||||
answer.AnswerText,
|
answer.AnswerText,
|
||||||
answer.Comment,
|
answer.Comment,
|
||||||
location.RegionId,
|
location.RegionId,
|
||||||
LocationId = location.Id,
|
LocationId = location.Id,
|
||||||
answer.SurveyResponseId
|
answer.SurveyResponseId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//group records by answer and region
|
//group records by answer and region
|
||||||
var q = from e in result
|
var q = from e in result
|
||||||
@ -398,13 +454,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
g.Key.RegionId,
|
g.Key.RegionId,
|
||||||
Answers = new
|
Answers = new
|
||||||
{
|
{
|
||||||
g.Key.AnswerText,
|
g.Key.AnswerText,
|
||||||
Counter = g.Count()
|
Counter = g.Count()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//build the result
|
//build the result
|
||||||
|
|
||||||
List<dynamic> resultList = new List<dynamic>();
|
List<dynamic> resultList = new List<dynamic>();
|
||||||
@ -412,9 +468,9 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
var answers = from u in q.ToList()
|
var answers = from u in q.ToList()
|
||||||
where u.RegionId.Equals(region.Id)
|
where u.RegionId.Equals(region.Id)
|
||||||
select u.Answers;
|
select u.Answers;
|
||||||
|
|
||||||
resultList.Add(new { RegionId = region.Id, region.Name, region.Abbreviation, Answers = answers});
|
resultList.Add(new { RegionId = region.Id, region.Name, region.Abbreviation, Answers = answers });
|
||||||
}
|
}
|
||||||
//return the object result
|
//return the object result
|
||||||
return new { Regions = resultList };
|
return new { Regions = resultList };
|
||||||
@ -470,13 +526,24 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
|
|
||||||
//Method to get Survey Responses by surveyId
|
//Method to get Survey Responses by surveyId
|
||||||
private async Task<dynamic> getSurveyResponsesBySurveyIdAsync(int surveyId)
|
private async Task<dynamic> getSurveyResponsesBySurveyIdAsync(int surveyId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId).ToListAsync();
|
List<Db.SurveyResponse> surveyResonses = null;
|
||||||
|
Employee employee = null;
|
||||||
|
List<Employee> employees = null;
|
||||||
|
if (employeeid == 0)
|
||||||
|
{
|
||||||
|
surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId).ToListAsync();
|
||||||
|
employees = await employeeServiceProvider.getEmployeesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId && x.EmployeeId == employeeid).ToListAsync();
|
||||||
|
employee = await employeeServiceProvider.getEmployeeAsync(employeeid);
|
||||||
|
}
|
||||||
|
|
||||||
var employees = await employeeServiceProvider.getEmployeesAsync();
|
|
||||||
var answers = await answerServiceProvider.getAnswersAsync();
|
var answers = await answerServiceProvider.getAnswersAsync();
|
||||||
var questions = await questionServiceProvider.getQuestionsAsync();
|
var questions = await questionServiceProvider.getQuestionsAsync();
|
||||||
var surveyQuestions = from q in questions where q.SurveyId == surveyId select q;
|
var surveyQuestions = from q in questions where q.SurveyId == surveyId select q;
|
||||||
@ -484,32 +551,70 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
//var surveyQuestions = await questionServiceProvider.getSurveyQuestionsAsync(surveyId);
|
//var surveyQuestions = await questionServiceProvider.getSurveyQuestionsAsync(surveyId);
|
||||||
|
|
||||||
var attachments = await attachmentServiceProvider.getAttachmentsAsync();
|
var attachments = await attachmentServiceProvider.getAttachmentsAsync();
|
||||||
var result = from r in surveyResonses
|
|
||||||
select new
|
|
||||||
{
|
|
||||||
r.Id,
|
|
||||||
r.SurveyId,
|
|
||||||
r.LocationId,
|
|
||||||
r.EmployeeId,
|
|
||||||
r.ClientDevice,
|
|
||||||
r.KeyAnswerResult,
|
|
||||||
r.Longitute,
|
|
||||||
r.Latitude,
|
|
||||||
Employee = (from e in employees where e.Id == r.EmployeeId select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
|
||||||
answers = from ans in answers
|
|
||||||
where ans.SurveyResponseId == r.Id
|
|
||||||
select new
|
|
||||||
{
|
|
||||||
ans.Id,
|
|
||||||
ans.QuestionId,
|
|
||||||
ans.AnswerText,
|
|
||||||
ans.Comment,
|
|
||||||
Questions = (from q in surveyQuestions where q.Id == ans.QuestionId select new { q.Id, q.QuestionNumber, q.CategoryId, q.Text }).SingleOrDefault(),
|
|
||||||
Attachments = from att in attachments where att.AnswerId == ans.Id select new { att.Id, att.URI }
|
|
||||||
|
|
||||||
}
|
if (employeeid == 0)
|
||||||
};
|
{
|
||||||
return result;
|
var result = from r in surveyResonses
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
r.Id,
|
||||||
|
r.SurveyId,
|
||||||
|
r.LocationId,
|
||||||
|
r.EmployeeId,
|
||||||
|
r.ClientDevice,
|
||||||
|
r.KeyAnswerResult,
|
||||||
|
r.Longitute,
|
||||||
|
r.Latitude,
|
||||||
|
Employee = (from e in employees where e.Id == r.EmployeeId select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
||||||
|
answers = from ans in answers
|
||||||
|
where ans.SurveyResponseId == r.Id
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
ans.Id,
|
||||||
|
ans.QuestionId,
|
||||||
|
ans.AnswerText,
|
||||||
|
ans.Comment,
|
||||||
|
Questions = (from q in surveyQuestions where q.Id == ans.QuestionId select new { q.Id, q.QuestionNumber, q.CategoryId, q.Text }).SingleOrDefault(),
|
||||||
|
Attachments = from att in attachments where att.AnswerId == ans.Id select new { att.Id, att.URI }
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
object _employee = new { };
|
||||||
|
if (employee != null)
|
||||||
|
{
|
||||||
|
_employee = new { employee.Id, employee.Name, employee.BirthDate, employee.Email, employee.OfficePhoneNumber };
|
||||||
|
}
|
||||||
|
var result = from r in surveyResonses
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
r.Id,
|
||||||
|
r.SurveyId,
|
||||||
|
r.LocationId,
|
||||||
|
r.EmployeeId,
|
||||||
|
r.ClientDevice,
|
||||||
|
r.KeyAnswerResult,
|
||||||
|
r.Longitute,
|
||||||
|
r.Latitude,
|
||||||
|
Employee = _employee,
|
||||||
|
answers = from ans in answers
|
||||||
|
where ans.SurveyResponseId == r.Id
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
ans.Id,
|
||||||
|
ans.QuestionId,
|
||||||
|
ans.AnswerText,
|
||||||
|
ans.Comment,
|
||||||
|
Questions = (from q in questions where q.Id == ans.QuestionId select new { q.Id, q.QuestionNumber, q.CategoryId, q.Text }).SingleOrDefault(),
|
||||||
|
Attachments = from att in attachments where att.AnswerId == ans.Id select new { att.Id, att.URI }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -520,13 +625,31 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
|
|
||||||
//Method to get All Survey Responses
|
//Method to get All Survey Responses
|
||||||
private async Task<dynamic> getAllSurveyResponsesAsync()
|
private async Task<dynamic> getAllSurveyResponsesAsync(int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var surveyResonses = await surveyResponseDbContext.SurveyResponses.ToListAsync();
|
List<Db.SurveyResponse> surveyResonses = null;
|
||||||
|
Employee employee = null;
|
||||||
|
List<Employee> employees = null;
|
||||||
|
object _employee = new { };
|
||||||
|
if (employeeid == 0)
|
||||||
|
{
|
||||||
|
surveyResonses = await surveyResponseDbContext.SurveyResponses.ToListAsync();
|
||||||
|
employees = await employeeServiceProvider.getEmployeesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).ToListAsync();
|
||||||
|
employee = await employeeServiceProvider.getEmployeeAsync(employeeid);
|
||||||
|
|
||||||
|
if (employee != null)
|
||||||
|
{
|
||||||
|
_employee = new { employee.Id, employee.Name, employee.BirthDate, employee.Email, employee.OfficePhoneNumber };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var employees = await employeeServiceProvider.getEmployeesAsync();
|
|
||||||
var answers = await answerServiceProvider.getAnswersAsync();
|
var answers = await answerServiceProvider.getAnswersAsync();
|
||||||
var questions = await questionServiceProvider.getQuestionsAsync();
|
var questions = await questionServiceProvider.getQuestionsAsync();
|
||||||
var attachments = await attachmentServiceProvider.getAttachmentsAsync();
|
var attachments = await attachmentServiceProvider.getAttachmentsAsync();
|
||||||
@ -542,7 +665,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
r.KeyAnswerResult,
|
r.KeyAnswerResult,
|
||||||
r.Longitute,
|
r.Longitute,
|
||||||
r.Latitude,
|
r.Latitude,
|
||||||
Employee = (from e in employees where r.EmployeeId == e.Id select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
Employee = employeeid != 0 ? _employee : (from e in employees where r.EmployeeId == e.Id select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
||||||
answers = from ans in answers
|
answers = from ans in answers
|
||||||
where ans.SurveyResponseId == r.Id
|
where ans.SurveyResponseId == r.Id
|
||||||
select new
|
select new
|
||||||
@ -556,6 +679,8 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -566,11 +691,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
|
|
||||||
//Method to get Answers By Maintenance Center by surveyId
|
//Method to get Answers By Maintenance Center by surveyId
|
||||||
private async Task<dynamic> getResultsByMaintenanceCenterAsync(int surveyId)
|
private async Task<dynamic> getResultsByMaintenanceCenterAsync(int surveyId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId).ToListAsync();
|
List<Db.SurveyResponse> surveyResponses = null;
|
||||||
|
if (employeeid == 0)
|
||||||
|
{
|
||||||
|
surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId).ToListAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId && x.EmployeeId == employeeid).ToListAsync();
|
||||||
|
}
|
||||||
var answers = await answerServiceProvider.getAnswersAsync();
|
var answers = await answerServiceProvider.getAnswersAsync();
|
||||||
var locations = await locationServiceProvider.getLocationsAsync();
|
var locations = await locationServiceProvider.getLocationsAsync();
|
||||||
var maintenanceCenters = locations.DistinctBy(m => m.MaintenanceCenter);
|
var maintenanceCenters = locations.DistinctBy(m => m.MaintenanceCenter);
|
||||||
@ -601,7 +734,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
g.Key.MaintenanceCenter,
|
g.Key.MaintenanceCenter,
|
||||||
Answers = new
|
Answers = new
|
||||||
{
|
{
|
||||||
g.Key.AnswerText,
|
g.Key.AnswerText,
|
||||||
Counter = g.Count()
|
Counter = g.Count()
|
||||||
@ -626,13 +759,31 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method to get Survey Responses by surveyId and LocationId
|
//Method to get Survey Responses by surveyId and LocationId
|
||||||
private async Task<dynamic> getSurveyResponsesBySurveyIdLocationIdAsync(int surveyId, int locationId)
|
private async Task<dynamic> getSurveyResponsesBySurveyIdLocationIdAsync(int surveyId, int locationId, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId && x.LocationId.Equals(locationId)).ToListAsync();
|
List<Db.SurveyResponse> surveyResonses = null;
|
||||||
|
Employee employee = null;
|
||||||
|
List<Employee> employees = null;
|
||||||
|
object _employee = new { };
|
||||||
|
|
||||||
|
if (employeeid == 0)
|
||||||
|
{
|
||||||
|
surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId && x.LocationId == locationId).ToListAsync();
|
||||||
|
employees = await employeeServiceProvider.getEmployeesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId && x.EmployeeId == employeeid && x.LocationId == locationId).ToListAsync();
|
||||||
|
employee = await employeeServiceProvider.getEmployeeAsync(employeeid);
|
||||||
|
|
||||||
|
if (employee != null)
|
||||||
|
{
|
||||||
|
_employee = new { employee.Id, employee.Name, employee.BirthDate, employee.Email, employee.OfficePhoneNumber };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var employees = await employeeServiceProvider.getEmployeesAsync();
|
|
||||||
var answers = await answerServiceProvider.getAnswersAsync();
|
var answers = await answerServiceProvider.getAnswersAsync();
|
||||||
var questions = await questionServiceProvider.getQuestionsAsync();
|
var questions = await questionServiceProvider.getQuestionsAsync();
|
||||||
var surveyQuestions = from q in questions where q.SurveyId == surveyId select q;
|
var surveyQuestions = from q in questions where q.SurveyId == surveyId select q;
|
||||||
@ -649,7 +800,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
r.KeyAnswerResult,
|
r.KeyAnswerResult,
|
||||||
r.Longitute,
|
r.Longitute,
|
||||||
r.Latitude,
|
r.Latitude,
|
||||||
Employee = (from e in employees where r.EmployeeId == e.Id select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
Employee = employeeid != 0 ? _employee : (from e in employees where r.EmployeeId == e.Id select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
||||||
answers = from ans in answers
|
answers = from ans in answers
|
||||||
where ans.SurveyResponseId == r.Id
|
where ans.SurveyResponseId == r.Id
|
||||||
|
|
||||||
@ -664,6 +815,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -674,13 +826,34 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
|
|
||||||
|
|
||||||
//Method to get Survey Responses by surveyId questionId and answer
|
//Method to get Survey Responses by surveyId questionId and answer
|
||||||
private async Task<dynamic> getSurveyResponsesByAnswerAsync(Survey survey, Question question, string answer)
|
private async Task<dynamic> getSurveyResponsesByAnswerAsync(Survey survey, Question question, string answer, int employeeid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == survey.Id).ToListAsync();
|
List<Db.SurveyResponse> surveyResponses = null;
|
||||||
|
Employee employee = null;
|
||||||
|
List<Employee> employees = null;
|
||||||
|
object _employee = new { };
|
||||||
|
|
||||||
|
if (employeeid == 0)
|
||||||
|
{
|
||||||
|
surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == survey.Id).ToListAsync();
|
||||||
|
employees = await employeeServiceProvider.getEmployeesAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == survey.Id && x.EmployeeId == employeeid).ToListAsync();
|
||||||
|
employee = await employeeServiceProvider.getEmployeeAsync(employeeid);
|
||||||
|
|
||||||
|
if (employee != null)
|
||||||
|
{
|
||||||
|
_employee = new { employee.Id, employee.Name, employee.BirthDate, employee.Email, employee.OfficePhoneNumber };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == survey.Id).ToListAsync();
|
||||||
|
// var employees = await employeeServiceProvider.getEmployeesAsync();
|
||||||
var answers = await answerServiceProvider.getAnswersAsync();
|
var answers = await answerServiceProvider.getAnswersAsync();
|
||||||
var employees = await employeeServiceProvider.getEmployeesAsync();
|
|
||||||
var attachments = await attachmentServiceProvider.getAttachmentsAsync();
|
var attachments = await attachmentServiceProvider.getAttachmentsAsync();
|
||||||
|
|
||||||
var result = from r in surveyResponses
|
var result = from r in surveyResponses
|
||||||
@ -694,7 +867,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
r.KeyAnswerResult,
|
r.KeyAnswerResult,
|
||||||
r.Longitute,
|
r.Longitute,
|
||||||
r.Latitude,
|
r.Latitude,
|
||||||
Employee = (from e in employees where r.EmployeeId == e.Id select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
Employee = employeeid != 0 ? _employee : (from e in employees where r.EmployeeId == e.Id select new { e.Id, e.Name, e.BirthDate, e.Email, e.OfficePhoneNumber }).SingleOrDefault(),
|
||||||
answers = from ans in answers
|
answers = from ans in answers
|
||||||
where ans.SurveyResponseId == r.Id
|
where ans.SurveyResponseId == r.Id
|
||||||
&& ans.QuestionId == question.Id
|
&& ans.QuestionId == question.Id
|
||||||
@ -757,7 +930,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
{
|
{
|
||||||
if (request != null)
|
if (request != null)
|
||||||
{
|
{
|
||||||
var response = await PostSurveyResponseAsync(new Models.SurveyResponse { SurveyId = request.SurveyId, EmployeeId = request.EmployeeId, LocationId = request.LocationId, ClientDevice = request.ClientDevice, KeyAnswerResult = request.KeyAnswerResult, Latitude = Convert.ToDouble(request.Latitude), Longitute = Convert.ToDouble(request.Longitute), CreatedDate=DateTime.Now });
|
var response = await PostSurveyResponseAsync(new Models.SurveyResponse { SurveyId = request.SurveyId, EmployeeId = request.EmployeeId, LocationId = request.LocationId, ClientDevice = request.ClientDevice, KeyAnswerResult = request.KeyAnswerResult, Latitude = Convert.ToDouble(request.Latitude), Longitute = Convert.ToDouble(request.Longitute), CreatedDate = DateTime.Now });
|
||||||
if (response.IsSuccess)
|
if (response.IsSuccess)
|
||||||
{
|
{
|
||||||
var surveyResponse = response.SurveyResponse;
|
var surveyResponse = response.SurveyResponse;
|
||||||
|
@ -4,16 +4,18 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.SurveyResponses.Services
|
namespace DamageAssesment.Api.SurveyResponses.Services
|
||||||
{
|
{
|
||||||
public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider
|
public class SurveyServiceProvider : ServiceProviderBase, ISurveyServiceProvider
|
||||||
{
|
{
|
||||||
public SurveyServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpUtil, logger, configuration.GetValue<string>("RessourceSettings:Survey"), 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"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Survey>> getSurveysAsync()
|
public async Task<List<Survey>> getSurveysAsync(string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(language))
|
||||||
|
url = url + "/" + language;
|
||||||
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
|
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
|
||||||
var surveys = JsonConvert.DeserializeObject<List<Survey>>(responseJsonString);
|
var surveys = JsonConvert.DeserializeObject<List<Survey>>(responseJsonString);
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services
|
|||||||
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
|
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
|
||||||
var survey = JsonConvert.DeserializeObject<Survey>(responseJsonString);
|
var survey = JsonConvert.DeserializeObject<Survey>(responseJsonString);
|
||||||
|
|
||||||
if (survey == null )
|
if (survey == null)
|
||||||
return null;
|
return null;
|
||||||
else return survey;
|
else return survey;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET request for retrieving surveys.
|
/// GET request for retrieving surveys.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[Route("Surveys")]
|
[Route("Surveys")]
|
||||||
[Route("Surveys/{language:alpha}")]
|
[Route("Surveys/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -47,7 +46,6 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// POST request for creating a new survey.
|
/// POST request for creating a new survey.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("Surveys")]
|
[HttpPost("Surveys")]
|
||||||
public async Task<ActionResult> PostSurveysAsync(Models.Survey survey)
|
public async Task<ActionResult> PostSurveysAsync(Models.Survey survey)
|
||||||
{
|
{
|
||||||
@ -61,8 +59,6 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// PUT request for updating an existing survey (surveyId,Updated Survey data).
|
/// PUT request for updating an existing survey (surveyId,Updated Survey data).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
|
|
||||||
[HttpPut("Surveys/{id}")]
|
[HttpPut("Surveys/{id}")]
|
||||||
public async Task<ActionResult> PutSurveysAsync(int id, Models.Survey survey)
|
public async Task<ActionResult> PutSurveysAsync(int id, Models.Survey survey)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DamageAssesment.Api.SurveyResponses\DamageAssesment.Api.SurveyResponses.csproj" />
|
<ProjectReference Include="..\DamageAssesment.Api.SurveyResponses\DamageAssesment.Api.Responses.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -3,10 +3,9 @@ using DamageAssesment.Api.SurveyResponses.Interfaces;
|
|||||||
using DamageAssesment.Api.SurveyResponses.Models;
|
using DamageAssesment.Api.SurveyResponses.Models;
|
||||||
using DamageAssesment.Api.SurveyResponses.Test;
|
using DamageAssesment.Api.SurveyResponses.Test;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Sdk;
|
|
||||||
|
|
||||||
namespace DamageAssesment.SurveyResponses.Test
|
namespace DamageAssesment.SurveyResponses.Test
|
||||||
{
|
{
|
||||||
@ -23,9 +22,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
{
|
{
|
||||||
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
var mockResponse = await MockData.getOkResponse(mockRequestObject);
|
var mockResponse = await MockData.getOkResponse(mockRequestObject);
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync(1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync();
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,9 +32,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode204()
|
public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode204()
|
||||||
{
|
{
|
||||||
var mockResponse = await MockData.getResponse();
|
var mockResponse = await MockData.getResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync(1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync();
|
var result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
||||||
Assert.Equal(400, result.StatusCode);
|
Assert.Equal(400, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
{
|
{
|
||||||
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
var mockResponse = await MockData.getOkResponse();
|
var mockResponse = await MockData.getOkResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1,1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
@ -54,7 +53,7 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode204()
|
public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode204()
|
||||||
{
|
{
|
||||||
var mockResponse = await MockData.getResponse();
|
var mockResponse = await MockData.getResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1,1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
||||||
Assert.Equal(204, result.StatusCode);
|
Assert.Equal(204, result.StatusCode);
|
||||||
@ -68,9 +67,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
{
|
{
|
||||||
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
var mockResponse = await MockData.getOkResponse();
|
var mockResponse = await MockData.getOkResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1,1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1);
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1,1);
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +77,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode204()
|
public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode204()
|
||||||
{
|
{
|
||||||
var mockResponse = await MockData.getResponse();
|
var mockResponse = await MockData.getResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1, 1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1);
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1, 1);
|
||||||
Assert.Equal(204, result.StatusCode);
|
Assert.Equal(204, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +88,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
{
|
{
|
||||||
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
var mockResponse = await MockData.getOkResponse();
|
var mockResponse = await MockData.getOkResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes",1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes");
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes",1);
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +98,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode204()
|
public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode204()
|
||||||
{
|
{
|
||||||
var mockResponse = await MockData.getResponse();
|
var mockResponse = await MockData.getResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes", 1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes");
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes",1);
|
||||||
Assert.Equal(204, result.StatusCode);
|
Assert.Equal(204, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +110,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
{
|
{
|
||||||
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
var mockResponse = await MockData.getOkResponse();
|
var mockResponse = await MockData.getOkResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1,1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1);
|
var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1, 1);
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +120,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode204()
|
public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode204()
|
||||||
{
|
{
|
||||||
var mockResponse = await MockData.getResponse();
|
var mockResponse = await MockData.getResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1, 1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1);
|
var result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1, 1);
|
||||||
Assert.Equal(204, result.StatusCode);
|
Assert.Equal(204, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,9 +131,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
{
|
{
|
||||||
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
var mockResponse = await MockData.getOkResponse();
|
var mockResponse = await MockData.getOkResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1, 1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1);
|
var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1, 1);
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,9 +141,9 @@ namespace DamageAssesment.SurveyResponses.Test
|
|||||||
public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode204()
|
public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode204()
|
||||||
{
|
{
|
||||||
var mockResponse = await MockData.getResponse();
|
var mockResponse = await MockData.getResponse();
|
||||||
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse);
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1, 1)).ReturnsAsync(mockResponse);
|
||||||
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
var result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1);
|
var result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1, 1);
|
||||||
Assert.Equal(204, result.StatusCode);
|
Assert.Equal(204, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,13 +17,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations", "DamageAssesment.Api.Locations\DamageAssesment.Api.Locations.csproj", "{746C67BF-9949-4361-B5D2-358C7607750E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations", "DamageAssesment.Api.Locations\DamageAssesment.Api.Locations.csproj", "{746C67BF-9949-4361-B5D2-358C7607750E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.SurveyResponses", "DamageAssesment.Api.SurveyResponses\DamageAssesment.Api.SurveyResponses.csproj", "{D11808FE-AD1C-4BA6-87FD-9D18B2DC81F2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Responses", "DamageAssesment.Api.SurveyResponses\DamageAssesment.Api.Responses.csproj", "{D11808FE-AD1C-4BA6-87FD-9D18B2DC81F2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Questions.Test", "DamageAssesment.Api.QuestionsTest\DamageAssesment.Api.Questions.Test.csproj", "{35CD9231-034D-4999-BCFC-1786DD007ED2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Questions.Test", "DamageAssesment.Api.QuestionsTest\DamageAssesment.Api.Questions.Test.csproj", "{35CD9231-034D-4999-BCFC-1786DD007ED2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Surveys.Test", "DamageAssesment.Api.Surveys.Test\DamageAssesment.Api.Surveys.Test.csproj", "{ADFB79E3-83C9-454F-A070-49D167BD28CC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Surveys.Test", "DamageAssesment.Api.Surveys.Test\DamageAssesment.Api.Surveys.Test.csproj", "{ADFB79E3-83C9-454F-A070-49D167BD28CC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.SurveyResponses.Test", "DamageAssesment.SurveyResponses.Test\DamageAssesment.Api.SurveyResponses.Test.csproj", "{6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Responses.Test", "DamageAssesment.SurveyResponses.Test\DamageAssesment.Api.Responses.Test.csproj", "{6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachments.Test", "DamageAssesment.Api.Attachments.Test\DamageAssesment.Api.Attachments.Test.csproj", "{730E5718-FCE1-42C0-AB76-EA020896A788}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachments.Test", "DamageAssesment.Api.Attachments.Test\DamageAssesment.Api.Attachments.Test.csproj", "{730E5718-FCE1-42C0-AB76-EA020896A788}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Loading…
Reference in New Issue
Block a user