From 46520c7e623a1f73557f17a329b59836311e2c9e Mon Sep 17 00:00:00 2001 From: Reginald CHERENFANT JASMIN Date: Tue, 26 Sep 2023 15:22:26 -0500 Subject: [PATCH] Update test case project for UserAccess and SurveyResponse modules. Renaming of SurveyResponses to Responses. --- ...esController.cs => ResponsesController.cs} | 60 ++++++-------- .../Db/SurveyResponse.cs | 2 +- .../Db/SurveyResponseDbContext.cs | 2 +- .../Interfaces/IAnswerServiceProvider.cs | 4 +- .../Interfaces/IAttachmentServiceProvider.cs | 4 +- .../Interfaces/IEmployeeServiceProvider.cs | 4 +- .../Interfaces/IHttpUtil.cs | 4 +- .../Interfaces/ILocationServiceProvider.cs | 4 +- .../Interfaces/IQuestionServiceProvider.cs | 4 +- .../Interfaces/IRegionServiceProvider.cs | 4 +- .../Interfaces/ISurveyServiceProvider.cs | 4 +- .../Interfaces/ISurveysResponse.cs | 21 +++-- .../Models/Answer.cs | 2 +- .../Models/AnswerRequest.cs | 2 +- .../Models/Attachment.cs | 2 +- .../Models/AttachmentInfo.cs | 2 +- .../Models/Employee.cs | 2 +- .../Models/Location.cs | 2 +- .../Models/Question.cs | 2 +- .../Models/Region.cs | 2 +- .../Models/Request.cs | 2 +- .../Models/Survey.cs | 2 +- .../Models/SurveyQuestion.cs | 2 +- .../Models/SurveyResponse.cs | 2 +- .../Models/SurveyTranslation.cs | 2 +- .../Profiles/SurveyResponsesProvider.cs | 2 +- .../Program.cs | 8 +- .../Properties/launchSettings.json | 2 +- .../Providers/SurveyResponsesProvider.cs | 77 ++++++++++------- .../Services/AnswerServiceProvider.cs | 6 +- .../Services/AttachmentServiceProvider.cs | 6 +- .../Services/EmployeeServiceProvider.cs | 6 +- .../Services/HttpUtil.cs | 6 +- .../Services/LocationServiceProvider.cs | 6 +- .../Services/QuestionServiceProvider.cs | 6 +- .../Services/RegionServiceProvider.cs | 6 +- .../Services/ServiceProviderBase.cs | 4 +- .../Services/SurveyServiceProvider.cs | 6 +- .../Controllers/UsersAccessController.cs | 10 --- .../MockData.cs | 4 +- ...ServiceTest.cs => ResponsesServiceTest.cs} | 83 +++++++++---------- DamageAssesmentApi/DamageAssesment.sln | 1 + 42 files changed, 187 insertions(+), 195 deletions(-) rename DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/{SurveyResponsesController.cs => ResponsesController.cs} (85%) rename DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/{SurveyResponsesServiceTest.cs => ResponsesServiceTest.cs} (76%) diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/ResponsesController.cs similarity index 85% rename from DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs rename to DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/ResponsesController.cs index 2d90851..08290e9 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/ResponsesController.cs @@ -1,36 +1,26 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace DamageAssesment.Api.SurveyResponses.Controllers +namespace DamageAssesment.Api.Responses.Controllers { [ApiController] - public class SurveyResponsesController : ControllerBase + public class ResponsesController : ControllerBase { private readonly ISurveysResponse surveyResponseProvider; - private string token; - private readonly IHttpContextAccessor httpContextAccessor; - public SurveyResponsesController(ISurveysResponse surveyResponseProvider, IHttpContextAccessor httpContextAccessor) + public ResponsesController(ISurveysResponse surveyResponseProvider) { this.surveyResponseProvider = surveyResponseProvider; - this.httpContextAccessor = httpContextAccessor; - token = httpContextAccessor.HttpContext.Request.Headers.Authorization; - if (token != null) - { - token = token.Replace("Bearer ", string.Empty); - } else - { - token = ""; - } } /// /// GET request for retrieving survey responses. /// - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses")] public async Task GetSurveyResponsesAsync() { - var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(token); + var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(); if (result.IsSuccess) { return Ok(result.surveyResponses); @@ -44,11 +34,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// GET request for retrieving survey responses by survey ID. /// - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses/BySurvey/{surveyid}")] public async Task GetSurveyResponsesAsync(int surveyid) { - var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid, token); + var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -60,11 +50,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The ID of the survey for which responses are to be retrieved. /// The ID of the location for which responses are to be retrieved. - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses/{surveyid}/{locationid}")] public async Task GetSurveyResponsesBySurveyAndLocationAsync(int surveyid, int locationid) { - var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyid, locationid, token); + var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyid, locationid); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -78,11 +68,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// The ID of the survey for which responses are to be retrieved. /// The ID of the question for which responses are to be retrieved. /// The answer for which responses are to be retrieved. - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses/ByAnswer/{surveyid}/{questionid}/{answer}")] public async Task GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer) { - var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer, token); + var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -94,11 +84,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// GET request for retrieving answers from survey responses by survey ID and region. /// /// The ID of the survey for which answers are to be retrieved. - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses/ByRegion/{surveyid}")] public async Task GetAnswersByRegionAsync(int surveyid) { - var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid, token); + var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid); if (result.IsSuccess) { return Ok(result.Answers); @@ -109,11 +99,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// GET request for retrieving survey responses by survey ID and maintenance center. /// /// The ID of the survey for which responses are to be retrieved. - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses/ByMaintenanceCenter/{surveyid}")] public async Task GetAnswersByMaintenaceCentersync(int surveyid) { - var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid, token); + var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -124,11 +114,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// GET request for retrieving a survey response by response ID. /// /// The ID of the survey response to be retrieved. - + [Authorize(Roles = "admin,survey,user,report")] [HttpGet("Responses/{id}")] public async Task GetSurveyResponseByIdAsync(int id) { - var result = await this.surveyResponseProvider.GetSurveyResponseByIdAsync(id, token); + var result = await this.surveyResponseProvider.GetSurveyResponseByIdAsync(id); if (result.IsSuccess) { return Ok(result.SurveyResponse); @@ -140,7 +130,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// POST request for creating a new survey response. /// /// The survey response object to be created. - + [Authorize(Roles = "admin,survey,user,report")] [HttpPost("Responses")] public async Task PostSurveysAsync(Models.SurveyResponse surveyResponse) { @@ -156,7 +146,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The ID of the survey response to be updated. /// The updated survey response object. - + [Authorize(Roles = "admin,survey,user,report")] [HttpPut("Responses/{id}")] public async Task PutSurveyResponseAsync(int id, Models.SurveyResponse surveyResponse) { @@ -173,7 +163,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// DELETE request for deleting an existing survey response. /// - + [Authorize(Roles = "admin,survey,user,report")] [HttpDelete("Responses/{id}")] public async Task DeleteSurveyResponseAsync(int id) { @@ -188,11 +178,11 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// POST request for submitting survey with multiple answers. /// /// The answers to be submitted for the survey. - + [Authorize(Roles = "admin,survey,user,report")] [HttpPost("Responses/Answers")] public async Task PostSurveyAnswersAsync(Request request) { - var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(request, token); + var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(request); if (result.IsSuccess) return Ok(result.SurveyResponse); diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponse.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponse.cs index 2169097..14704cb 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponse.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponse.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace DamageAssesment.Api.SurveyResponses.Db +namespace DamageAssesment.Api.Responses.Db { public class SurveyResponse { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponseDbContext.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponseDbContext.cs index 61726ad..c1fae2d 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponseDbContext.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Db/SurveyResponseDbContext.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace DamageAssesment.Api.SurveyResponses.Db +namespace DamageAssesment.Api.Responses.Db { public class SurveyResponseDbContext:DbContext { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAnswerServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAnswerServiceProvider.cs index 2517daa..7c23f55 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAnswerServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAnswerServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface IAnswerServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAttachmentServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAttachmentServiceProvider.cs index f22c3d0..15f76a5 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAttachmentServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IAttachmentServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface IAttachmentServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IEmployeeServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IEmployeeServiceProvider.cs index 9b1d2e1..b7f8143 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IEmployeeServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IEmployeeServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface IEmployeeServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IHttpUtil.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IHttpUtil.cs index f262fa5..cf63c3b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IHttpUtil.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IHttpUtil.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface IHttpUtil { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ILocationServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ILocationServiceProvider.cs index aae34b0..75ab80e 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ILocationServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ILocationServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface ILocationServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IQuestionServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IQuestionServiceProvider.cs index 4530034..b37a171 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IQuestionServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IQuestionServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface IQuestionServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IRegionServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IRegionServiceProvider.cs index 1d26e11..a97193e 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IRegionServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/IRegionServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface IRegionServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs index 7609d1d..60de3bd 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface ISurveyServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs index de31140..180c723 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs @@ -1,23 +1,22 @@ -using DamageAssesment.Api.SurveyResponses.Models; -using Microsoft.AspNetCore.Mvc; +using DamageAssesment.Api.Responses.Models; -namespace DamageAssesment.Api.SurveyResponses.Interfaces +namespace DamageAssesment.Api.Responses.Interfaces { public interface ISurveysResponse { - Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId, string token); + Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId); 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)> GetSurveyResponsesAsync(string token); + Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync(); 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, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId, string token); - Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId, string token); - Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId, string token); - Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId, string token); - Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer, string token); + 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)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId); + Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId); + Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer); - Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Request request, string token); + Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Request request); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Answer.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Answer.cs index d607a2f..d507630 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Answer.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Answer.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Answer { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AnswerRequest.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AnswerRequest.cs index 3d86488..2921faf 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AnswerRequest.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AnswerRequest.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class AnswerRequest { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Attachment.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Attachment.cs index 92ab874..6194789 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Attachment.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Attachment.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Attachment { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AttachmentInfo.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AttachmentInfo.cs index e3e30b9..8c31831 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AttachmentInfo.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/AttachmentInfo.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class AttachmentInfo { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Employee.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Employee.cs index ab21448..3a84d81 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Employee.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Employee.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Employee { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Location.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Location.cs index 078a5ef..d5996d2 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Location.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Location.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Location { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Question.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Question.cs index 37abb4b..aac31f5 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Question.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Question.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Question { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Region.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Region.cs index 3fc5ad7..0f3ee9d 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Region.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Region.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Region { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Request.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Request.cs index 5060914..322314d 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Request.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Request.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Request { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Survey.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Survey.cs index b47193e..8265046 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Survey.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/Survey.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class Survey { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyQuestion.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyQuestion.cs index d510b4e..da3668f 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyQuestion.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyQuestion.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class SurveyQuestions { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyResponse.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyResponse.cs index 37862ca..56d2048 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyResponse.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyResponse.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class SurveyResponse { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyTranslation.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyTranslation.cs index 29a1b7c..022172f 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyTranslation.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Models/SurveyTranslation.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Models +namespace DamageAssesment.Api.Responses.Models { public class SurveyTranslation { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Profiles/SurveyResponsesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Profiles/SurveyResponsesProvider.cs index d7c65a0..8208db7 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Profiles/SurveyResponsesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Profiles/SurveyResponsesProvider.cs @@ -1,4 +1,4 @@ -namespace DamageAssesment.Api.SurveyResponses.Profiles +namespace DamageAssesment.Api.Responses.Profiles { public class SurveyResponsesProvider : AutoMapper.Profile { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs index 550d49c..82f2076 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Program.cs @@ -1,7 +1,7 @@ -using DamageAssesment.Api.SurveyResponses.Db; -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Services; -using DamageAssesment.Api.SurveyResponses.Providers; +using DamageAssesment.Api.Responses.Db; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Services; +using DamageAssesment.Api.Responses.Providers; using Microsoft.EntityFrameworkCore; using Polly; using System.Reflection; diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Properties/launchSettings.json b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Properties/launchSettings.json index 0d51b15..f43ced8 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Properties/launchSettings.json +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Properties/launchSettings.json @@ -9,7 +9,7 @@ } }, "profiles": { - "DamageAssesment.Api.SurveyResponses": { + "DamageAssesment.Api.Responses": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs index d3641b1..eaba58f 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs @@ -1,10 +1,10 @@ using AutoMapper; -using DamageAssesment.Api.SurveyResponses.Db; -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Db; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Microsoft.EntityFrameworkCore; -namespace DamageAssesment.Api.SurveyResponses.Providers +namespace DamageAssesment.Api.Responses.Providers { public class SurveyResponsesProvider : ISurveysResponse { @@ -18,8 +18,10 @@ namespace DamageAssesment.Api.SurveyResponses.Providers private readonly IQuestionServiceProvider questionServiceProvider; private readonly ISurveyServiceProvider surveyServiceProvider; private readonly IMapper mapper; + private readonly IHttpContextAccessor httpContextAccessor; + private string token; - public SurveyResponsesProvider(SurveyResponseDbContext surveyResponseDbContext, ILogger logger, IAnswerServiceProvider answerServiceProvider, IRegionServiceProvider regionServiceProvider, ILocationServiceProvider locationServiceProvider, IEmployeeServiceProvider employeeServiceProvider, IAttachmentServiceProvider attachmentServiceProvider, IQuestionServiceProvider questionServiceProvider, ISurveyServiceProvider surveyServiceProvider, IMapper mapper) + public SurveyResponsesProvider(SurveyResponseDbContext surveyResponseDbContext, ILogger logger, IAnswerServiceProvider answerServiceProvider, IRegionServiceProvider regionServiceProvider, ILocationServiceProvider locationServiceProvider, IEmployeeServiceProvider employeeServiceProvider, IAttachmentServiceProvider attachmentServiceProvider, IQuestionServiceProvider questionServiceProvider, ISurveyServiceProvider surveyServiceProvider, IMapper mapper, IHttpContextAccessor httpContextAccessor) { this.surveyResponseDbContext = surveyResponseDbContext; this.logger = logger; @@ -30,8 +32,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers this.attachmentServiceProvider = attachmentServiceProvider; this.questionServiceProvider = questionServiceProvider; this.surveyServiceProvider = surveyServiceProvider; + this.httpContextAccessor = httpContextAccessor; this.mapper = mapper; - // seedData(); + + token = httpContextAccessor.HttpContext.Request.Headers.Authorization; + if (token != null) + { + token = token.Replace("Bearer ", string.Empty); + } + else + { + token = ""; + } + // seedData(); } private void seedData() @@ -42,13 +55,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 2, SurveyId = 1, EmployeeId = 2, LocationId = 2, ClientDevice = "Desktop", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "true", CreatedDate = DateTime.Now }); surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 3, SurveyId = 3, EmployeeId = 4, LocationId = 1, ClientDevice = "Mobile", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "true", CreatedDate = DateTime.Now }); surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 4, SurveyId = 4, EmployeeId = 1, LocationId = 2, ClientDevice = "Desktop", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "false", CreatedDate = DateTime.Now }); - surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 6, SurveyId = 1, EmployeeId = 4, LocationId = 2, ClientDevice = "Desktop", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "true", CreatedDate = DateTime.Now }); - surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 7, SurveyId = 1, EmployeeId = 4, LocationId = 3, ClientDevice = "Desktop", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "false", CreatedDate = DateTime.Now }); + surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 5, SurveyId = 1, EmployeeId = 4, LocationId = 2, ClientDevice = "Desktop", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "true", CreatedDate = DateTime.Now }); + surveyResponseDbContext.SurveyResponses.Add(new Db.SurveyResponse { Id = 6, SurveyId = 1, EmployeeId = 4, LocationId = 3, ClientDevice = "Desktop", Latitude = 98.8767, Longitute = -129.9897, KeyAnswerResult = "false", CreatedDate = DateTime.Now }); surveyResponseDbContext.SaveChanges(); } } - public async Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId,string token) + public async Task<(bool IsSuccess, dynamic Answers, string ErrorMessage)> GetAnswersByRegionAsync(int surveyId) { try { @@ -57,7 +70,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (listSurveyResponse.Any()) { - var answers = await getAnswersByRegionAndSurveyIdAsync(listSurveyResponse,token); + var answers = await getAnswersByRegionAndSurveyIdAsync(listSurveyResponse); return (true, answers, "Request Successful."); } else @@ -72,7 +85,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } } - public async Task<(bool IsSuccess, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId, string token) + public async Task<(bool IsSuccess, dynamic SurveyResponse, string ErrorMessage)> GetSurveyResponseByIdAsync(int responseId) { try { @@ -81,7 +94,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (surveyResponse != null) { - var answers = await getSurveyResponseByResponseIdAsync(surveyResponse, token); + var answers = await getSurveyResponseByResponseIdAsync(surveyResponse); if (answers != null) return (true, answers, "Request Successful."); @@ -105,7 +118,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers - public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId, string token) + public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId) { try { @@ -114,7 +127,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null) { - var answers = await getSurveyResponsesBySurveyIdAsync(surveyId, token); + var answers = await getSurveyResponsesBySurveyIdAsync(surveyId); if (answers != null) return (true, answers, "Request Successful."); @@ -136,7 +149,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } } - public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId, string token) + public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId) { try { @@ -145,7 +158,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null) { - var answers = await getSurveyResponsesBySurveyIdLocationIdAsync(surveyId, locationId, token); + var answers = await getSurveyResponsesBySurveyIdLocationIdAsync(surveyId, locationId); if (answers != null) return (true, answers, "Request Successful."); @@ -167,7 +180,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } } - public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId, string token) + public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesByMaintenanceCenterAsync(int surveyId) { try { @@ -176,7 +189,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null) { - var answers = await getResultsByMaintenanceCenterAsync(surveyId,token); + var answers = await getResultsByMaintenanceCenterAsync(surveyId); if (answers != null) return (true, answers, "Request Successful."); @@ -198,7 +211,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } } - public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer, string token) + public async Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetResponsesByAnswerAsync(int surveyId, int questionId, string answer) { try { @@ -210,7 +223,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null && question != null && IsCorrectAnswer) { - var answers = await getSurveyResponsesByAnswerAsync(survey, question, answer, token); + var answers = await getSurveyResponsesByAnswerAsync(survey, question, answer); if (answers != null) return (true, answers, "Request Successful."); @@ -233,11 +246,11 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } - public async Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync(string token) + public async Task<(bool IsSuccess, dynamic surveyResponses, string ErrorMessage)> GetSurveyResponsesAsync() { try { - var answers = await getAllSurveyResponsesAsync(token); + var answers = await getAllSurveyResponsesAsync(); if (answers != null) return (true, answers, "Request Successful."); @@ -341,7 +354,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } //Method to get Answers by region with surveyId as input parameter - private async Task getAnswersByRegionAndSurveyIdAsync(IQueryable surveyResponses, string token) + private async Task getAnswersByRegionAndSurveyIdAsync(IQueryable surveyResponses) { try { @@ -427,7 +440,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } //Method to get Survey Response by ResponseId - private async Task getSurveyResponseByResponseIdAsync(Db.SurveyResponse surveyResponse, string token) + private async Task getSurveyResponseByResponseIdAsync(Db.SurveyResponse surveyResponse) { try { @@ -470,7 +483,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get Survey Responses by surveyId - private async Task getSurveyResponsesBySurveyIdAsync(int surveyId, string token) + private async Task getSurveyResponsesBySurveyIdAsync(int surveyId) { try { @@ -519,7 +532,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get All Survey Responses - private async Task getAllSurveyResponsesAsync(string token) + private async Task getAllSurveyResponsesAsync() { try { @@ -564,7 +577,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get Answers By Maintenance Center by surveyId - private async Task getResultsByMaintenanceCenterAsync(int surveyId, string token) + private async Task getResultsByMaintenanceCenterAsync(int surveyId) { try { @@ -624,7 +637,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } //Method to get Survey Responses by surveyId and LocationId - private async Task getSurveyResponsesBySurveyIdLocationIdAsync(int surveyId, int locationId, string token) + private async Task getSurveyResponsesBySurveyIdLocationIdAsync(int surveyId, int locationId) { try { @@ -671,7 +684,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get Survey Responses by surveyId questionId and answer - private async Task getSurveyResponsesByAnswerAsync(Survey survey, Question question, string answer, string token) + private async Task getSurveyResponsesByAnswerAsync(Survey survey, Question question, string answer) { try { @@ -717,7 +730,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } - async Task ProcessAnswers(AnswerRequest answerRequest, int surveyResponseId,string token) + async Task ProcessAnswers(AnswerRequest answerRequest, int surveyResponseId) { if (answerRequest != null) { @@ -747,7 +760,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } } - public async Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Models.Request request, string token) + public async Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Models.Request request) { try { @@ -757,7 +770,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (response.IsSuccess) { var surveyResponse = response.SurveyResponse; - var tasks = request.Answers.Select(x => ProcessAnswers(x, surveyResponse.Id,token)); + var tasks = request.Answers.Select(x => ProcessAnswers(x, surveyResponse.Id)); await Task.WhenAll(tasks); return (true, surveyResponse, null); } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AnswerServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AnswerServiceProvider.cs index 5ee1a39..b550ff1 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AnswerServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AnswerServiceProvider.cs @@ -1,10 +1,10 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Microsoft.Extensions.Primitives; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class AnswerServiceProvider : ServiceProviderBase, IAnswerServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AttachmentServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AttachmentServiceProvider.cs index 25601fe..9ace258 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AttachmentServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/AttachmentServiceProvider.cs @@ -1,8 +1,8 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class AttachmentServiceProvider : ServiceProviderBase, IAttachmentServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/EmployeeServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/EmployeeServiceProvider.cs index 0a598a6..507fc18 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/EmployeeServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/EmployeeServiceProvider.cs @@ -1,9 +1,9 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Microsoft.AspNetCore.Mvc.Routing; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class EmployeeServiceProvider : ServiceProviderBase, IEmployeeServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/HttpUtil.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/HttpUtil.cs index 09e3582..3f8ca2d 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/HttpUtil.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/HttpUtil.cs @@ -1,9 +1,9 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using System.Net.Http.Headers; using System.Text; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class HttpUtil : IHttpUtil { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/LocationServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/LocationServiceProvider.cs index 62ebf09..2d38ca3 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/LocationServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/LocationServiceProvider.cs @@ -1,8 +1,8 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/QuestionServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/QuestionServiceProvider.cs index 9f163c2..4f2e75f 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/QuestionServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/QuestionServiceProvider.cs @@ -1,8 +1,8 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class QuestionServiceProvider : ServiceProviderBase, IQuestionServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/RegionServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/RegionServiceProvider.cs index 1b6ea07..13de3d6 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/RegionServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/RegionServiceProvider.cs @@ -1,8 +1,8 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class RegionServiceProvider : ServiceProviderBase, IRegionServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/ServiceProviderBase.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/ServiceProviderBase.cs index af1aa65..1196f5b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/ServiceProviderBase.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/ServiceProviderBase.cs @@ -1,6 +1,6 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; +using DamageAssesment.Api.Responses.Interfaces; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class ServiceProviderBase { diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs index fc08135..2e9732e 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs @@ -1,8 +1,8 @@ -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; -namespace DamageAssesment.Api.SurveyResponses.Services +namespace DamageAssesment.Api.Responses.Services { public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider { diff --git a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs index b8b2760..e0aae67 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.UsersAccess/Controllers/UsersAccessController.cs @@ -2,8 +2,6 @@ using DamageAssesment.Api.UsersAccess.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using System.IdentityModel.Tokens.Jwt; -using System.IO; namespace DamageAssesment.Api.UsersAccess.Controllers { @@ -20,14 +18,6 @@ namespace DamageAssesment.Api.UsersAccess.Controllers [HttpPost("token/{employecode}")] public async Task AuthenticateAsync(string employecode) { - /* if (Request.Headers.TryGetValue("Authorization", out var headerAuth)) - { - var jwtToken = headerAuth.First().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1]; - var handler = new JwtSecurityTokenHandler(); - var jsonToken = handler.ReadToken(jwtToken) as JwtSecurityToken; - return Ok(jsonToken.Payload.Sub); - } */ - var result = await userAccessProvider.AuthenticateAsync(employecode); if (result.IsSuccess) { diff --git a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/MockData.cs b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/MockData.cs index 5be421f..c7a52de 100644 --- a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/MockData.cs +++ b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/MockData.cs @@ -1,9 +1,9 @@  -using DamageAssesment.Api.SurveyResponses.Models; +using DamageAssesment.Api.Responses.Models; using System.Collections.Generic; using System.Text; -namespace DamageAssesment.Api.SurveyResponses.Test +namespace DamageAssesment.Api.Responses.Test { public class MockData { diff --git a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/ResponsesServiceTest.cs similarity index 76% rename from DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs rename to DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/ResponsesServiceTest.cs index 593038d..57e3630 100644 --- a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs +++ b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/ResponsesServiceTest.cs @@ -1,20 +1,19 @@ -using DamageAssesment.Api.SurveyResponses.Controllers; -using DamageAssesment.Api.SurveyResponses.Interfaces; -using DamageAssesment.Api.SurveyResponses.Models; -using DamageAssesment.Api.SurveyResponses.Test; +using DamageAssesment.Api.Responses.Controllers; +using DamageAssesment.Api.Responses.Interfaces; +using DamageAssesment.Api.Responses.Models; +using DamageAssesment.Api.Responses.Test; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore.Infrastructure; using Moq; using Xunit; -using Xunit.Sdk; + namespace DamageAssesment.SurveyResponses.Test { - public class SurveyResponsesServiceTest + public class ResponsesServiceTest { private Mock mockSurveyResponseService; private string token { get; set; } - public SurveyResponsesServiceTest() + public ResponsesServiceTest() { mockSurveyResponseService = new Mock(); token = Guid.NewGuid().ToString(); @@ -25,8 +24,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(mockRequestObject); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync(token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(); Assert.Equal(200, result.StatusCode); } @@ -35,8 +34,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync(token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(); Assert.Equal(400, result.StatusCode); } @@ -46,8 +45,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); Assert.Equal(200, result.StatusCode); } @@ -56,8 +55,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); Assert.Equal(204, result.StatusCode); } @@ -70,8 +69,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1); Assert.Equal(200, result.StatusCode); } @@ -80,8 +79,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1); Assert.Equal(204, result.StatusCode); } @@ -91,8 +90,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes", token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes"); Assert.Equal(200, result.StatusCode); } @@ -101,8 +100,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes", token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes"); Assert.Equal(204, result.StatusCode); } @@ -113,8 +112,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1); Assert.Equal(200, result.StatusCode); } @@ -123,8 +122,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1); Assert.Equal(204, result.StatusCode); } @@ -134,8 +133,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1); Assert.Equal(200, result.StatusCode); } @@ -144,8 +143,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1); Assert.Equal(204, result.StatusCode); } @@ -155,8 +154,8 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponseByIdAsync(1); Assert.Equal(200, result.StatusCode); } @@ -165,8 +164,8 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesByResponseIdyAsync_ShouldReturnStatusCode204() { var mockResponse = await MockData.getResponse(); - mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1, token)).ReturnsAsync(mockResponse); - var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object); + mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1)).ReturnsAsync(mockResponse); + var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object); var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponseByIdAsync(1); Assert.Equal(204, result.StatusCode); } @@ -178,7 +177,7 @@ namespace DamageAssesment.SurveyResponses.Test SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(mockRequestObject); mockSurveyResponseService.Setup(service => service.PostSurveyResponseAsync(mockRequestObject)).ReturnsAsync(mockResponse); - var surveyResponseController = new SurveyResponsesController(mockSurveyResponseService.Object); + var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseController.PostSurveysAsync(mockRequestObject); Assert.Equal(200, result.StatusCode); } @@ -189,7 +188,7 @@ namespace DamageAssesment.SurveyResponses.Test SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getResponse(); mockSurveyResponseService.Setup(service => service.PostSurveyResponseAsync(mockRequestObject)).ReturnsAsync(mockResponse); - var surveyResponseController = new SurveyResponsesController(mockSurveyResponseService.Object); + var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); var result = (BadRequestObjectResult)await surveyResponseController.PostSurveysAsync(mockRequestObject); Assert.Equal(400, result.StatusCode); } @@ -200,7 +199,7 @@ namespace DamageAssesment.SurveyResponses.Test SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(mockRequestObject); mockSurveyResponseService.Setup(service => service.PutSurveyResponseAsync(1, mockRequestObject)).ReturnsAsync(mockResponse); - var surveyResponseController = new SurveyResponsesController(mockSurveyResponseService.Object); + var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseController.PutSurveyResponseAsync(1, mockRequestObject); Assert.Equal(200, result.StatusCode); } @@ -211,7 +210,7 @@ namespace DamageAssesment.SurveyResponses.Test SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getResponse(); mockSurveyResponseService.Setup(service => service.PutSurveyResponseAsync(1, mockRequestObject)).ReturnsAsync(mockResponse); ; - var surveyResponseController = new SurveyResponsesController(mockSurveyResponseService.Object); + var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); var result = (BadRequestObjectResult)await surveyResponseController.PutSurveyResponseAsync(1, mockRequestObject); Assert.Equal(400, result.StatusCode); } @@ -222,7 +221,7 @@ namespace DamageAssesment.SurveyResponses.Test SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); var mockResponse = await MockData.getOkResponse(mockRequestObject); mockSurveyResponseService.Setup(service => service.DeleteSurveyResponseAsync(1)).ReturnsAsync(mockResponse); - var surveyResponseController = new SurveyResponsesController(mockSurveyResponseService.Object); + var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); var result = (OkObjectResult)await surveyResponseController.DeleteSurveyResponseAsync(1); Assert.Equal(200, result.StatusCode); } @@ -232,7 +231,7 @@ namespace DamageAssesment.SurveyResponses.Test { var mockResponse = await MockData.getResponse(); mockSurveyResponseService.Setup(service => service.DeleteSurveyResponseAsync(1)).ReturnsAsync(mockResponse); ; - var surveyResponseController = new SurveyResponsesController(mockSurveyResponseService.Object); + var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object); var result = (NotFoundResult)await surveyResponseController.DeleteSurveyResponseAsync(1); Assert.Equal(404, result.StatusCode); } diff --git a/DamageAssesmentApi/DamageAssesment.sln b/DamageAssesmentApi/DamageAssesment.sln index 7efdefc..e3f518b 100644 --- a/DamageAssesmentApi/DamageAssesment.sln +++ b/DamageAssesmentApi/DamageAssesment.sln @@ -80,6 +80,7 @@ Global {ADFB79E3-83C9-454F-A070-49D167BD28CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {ADFB79E3-83C9-454F-A070-49D167BD28CC}.Release|Any CPU.Build.0 = Release|Any CPU {6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}.Debug|Any CPU.Build.0 = Debug|Any CPU {6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}.Release|Any CPU.Build.0 = Release|Any CPU {730E5718-FCE1-42C0-AB76-EA020896A788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU