diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs index e5f3917..22d9f6b 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Controllers/SurveyResponsesController.cs @@ -1,8 +1,6 @@ using DamageAssesment.Api.SurveyResponses.Interfaces; using DamageAssesment.Api.SurveyResponses.Models; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; namespace DamageAssesment.Api.SurveyResponses.Controllers { @@ -19,10 +17,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// GET request for retrieving survey responses. /// - [HttpGet("Responses")] - public async Task GetSurveyResponsesAsync() + [Route("Responses/{employeeid:int}")] + [Route("Responses")] + [HttpGet] + public async Task GetSurveyResponsesAsync(int? employeeid) { - var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(); + var result = await this.surveyResponseProvider.GetSurveyResponsesAsync(employeeid ?? 0); if (result.IsSuccess) { return Ok(result.surveyResponses); @@ -36,11 +36,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// GET request for retrieving survey responses by survey ID. /// - - [HttpGet("Responses/BySurvey/{surveyid}")] - public async Task GetSurveyResponsesAsync(int surveyid) + [Route("Responses/BySurvey/{surveyid:int}/{employeeid:int}")] + [Route("Responses/BySurvey/{surveyid:int}")] + [HttpGet] + public async Task GetSurveyResponsesAsync(int surveyid, int? employeeid) { - var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid); + var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyid, employeeid ?? 0); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -53,15 +54,16 @@ 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. - [HttpGet("Responses/{surveyid}/{locationid}")] - public async Task GetSurveyResponsesBySurveyAndLocationAsync(int surveyid, int locationid) + [Route("Responses/{surveyid:int}/{locationid:int}/{employeeid:int}")] + [Route("Responses/{surveyid:int}/{locationid:int}")] + [HttpGet] + public async Task 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) { return Ok(result.SurveyResponses); } - return NoContent(); } /// @@ -71,10 +73,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// The ID of the question for which responses are to be retrieved. /// The answer for which responses are to be retrieved. - [HttpGet("Responses/ByAnswer/{surveyid}/{questionid}/{answer}")] - public async Task GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer) - { - var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer); + [Route("Responses/ByAnswer/{surveyid:int}/{questionid:int}/{answer:alpha}/{employeeid:int}")] + [Route("Responses/ByAnswer/{surveyid:int}/{questionid:int}/{answer:alpha}")] + [HttpGet] + public async Task GetSurveyResponsesByAnswerAsyncAsync(int surveyid, int questionid, string answer, int? employeeid) + { + var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyid, questionid, answer, employeeid ?? 0); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -87,10 +91,12 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// The ID of the survey for which answers are to be retrieved. - [HttpGet("Responses/ByRegion/{surveyid}")] - public async Task GetAnswersByRegionAsync(int surveyid) + [Route("Responses/ByRegion/{surveyid:int}")] + [Route("Responses/ByRegion/{surveyid:int}/{employeeid}")] + [HttpGet] + public async Task GetAnswersByRegionAsync(int surveyid, int? employeeid) { - var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid); + var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyid, employeeid ?? 0); if (result.IsSuccess) { 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. /// /// The ID of the survey for which responses are to be retrieved. - - [HttpGet("Responses/ByMaintenanceCenter/{surveyid}")] - public async Task GetAnswersByMaintenaceCentersync(int surveyid) + [Route("Responses/ByMaintenanceCenter/{surveyid:int}/{employeeid:int}")] + [Route("Responses/ByMaintenanceCenter/{surveyid:int}")] + [HttpGet] + public async Task GetAnswersByMaintenaceCentersync(int surveyid, int? employeeid) { - var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid); + var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyid, employeeid ?? 0); if (result.IsSuccess) { return Ok(result.SurveyResponses); @@ -165,7 +172,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers /// /// DELETE request for deleting an existing survey response. /// - + [HttpDelete("Responses/{id}")] public async Task DeleteSurveyResponseAsync(int id) { @@ -191,5 +198,31 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers else return BadRequest(result.ErrorMessage); } + + [Route("Responses/Surveys/active/{employeeid:int}")] + [Route("Responses/Surveys/active/{employeeid:int}/{language:alpha}")] + [HttpGet] + public async Task 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 GetHistoricSurveysAsync(int employeeid, string? language) + { + var result = await this.surveyResponseProvider.GetHistoricSurveysAsync(employeeid, language); + if (result.IsSuccess) + { + return Ok(result.Surveys); + } + return NoContent(); + } } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.Responses.csproj similarity index 100% rename from DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj rename to DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.Responses.csproj diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs index 97d6461..2b01d16 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveyServiceProvider.cs @@ -4,7 +4,7 @@ namespace DamageAssesment.Api.SurveyResponses.Interfaces { public interface ISurveyServiceProvider { - Task> getSurveysAsync(); + Task> getSurveysAsync(string language); Task getSurveyAsync(int surveyId); } } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs index 536353c..2bbab9a 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Interfaces/ISurveysResponse.cs @@ -5,18 +5,19 @@ namespace DamageAssesment.Api.SurveyResponses.Interfaces { 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,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)> DeleteSurveyResponseAsync(int Id); 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, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAsync(int surveyId, int employeeid); + Task<(bool IsSuccess, dynamic SurveyResponses, string ErrorMessage)> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, int locationId, int employeeid); + 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, int employeeid); Task<(bool IsSuccess, Models.SurveyResponse SurveyResponse, string ErrorMessage)> PostSurveyAnswersAsync(Request request); } diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs index 1f82d8c..03eada1 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Providers/SurveyResponsesProvider.cs @@ -31,7 +31,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers this.questionServiceProvider = questionServiceProvider; this.surveyServiceProvider = surveyServiceProvider; this.mapper = mapper; - // seedData(); + // 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 { logger?.LogInformation("Querying to get SurveyResponse object from DB"); - var listSurveyResponse = surveyResponseDbContext.SurveyResponses.Where(s => s.SurveyId == surveyId); + IQueryable 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()) { @@ -102,10 +110,58 @@ namespace DamageAssesment.Api.SurveyResponses.Providers 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 { @@ -114,7 +170,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null) { - var answers = await getSurveyResponsesBySurveyIdAsync(surveyId); + var answers = await getSurveyResponsesBySurveyIdAsync(surveyId, employeeid); if (answers != null) 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 { @@ -145,7 +201,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null) { - var answers = await getSurveyResponsesBySurveyIdLocationIdAsync(surveyId, locationId); + var answers = await getSurveyResponsesBySurveyIdLocationIdAsync(surveyId, locationId, employeeid); if (answers != null) 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 { @@ -176,7 +232,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null) { - var answers = await getResultsByMaintenanceCenterAsync(surveyId); + var answers = await getResultsByMaintenanceCenterAsync(surveyId, employeeid); if (answers != null) 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 { @@ -210,7 +266,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers if (survey != null && question != null && IsCorrectAnswer) { - var answers = await getSurveyResponsesByAnswerAsync(survey, question, answer); + var answers = await getSurveyResponsesByAnswerAsync(survey, question, answer, employeeid); if (answers != null) 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 { - var answers = await getAllSurveyResponsesAsync(); + var responses = await getAllSurveyResponsesAsync(employeeid); - if (answers != null) - return (true, answers, "Request Successful."); + if (responses != null) + return (true, responses, "Request Successful."); else { - answers = new List(); - return (true, answers, "Empty object returned"); + responses = new List(); + return (true, responses, "Empty object returned"); } } catch (Exception ex) @@ -355,7 +411,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers answer => answer.SurveyResponseId, surveyResponse => surveyResponse.Id, (answer, surveyResponse) => new - + { answer.Id, answer.QuestionId, @@ -379,18 +435,18 @@ namespace DamageAssesment.Api.SurveyResponses.Providers var result = from answer in surveyAnswers from location in locations where answer.LocationId.Equals(location.Id) - select new + select new { - answer.Id, - answer.QuestionId, - answer.AnswerText, - answer.Comment, - location.RegionId, - LocationId = location.Id, - answer.SurveyResponseId + answer.Id, + answer.QuestionId, + answer.AnswerText, + answer.Comment, + location.RegionId, + LocationId = location.Id, + answer.SurveyResponseId }; - + //group records by answer and region var q = from e in result @@ -398,13 +454,13 @@ namespace DamageAssesment.Api.SurveyResponses.Providers select new { g.Key.RegionId, - Answers = new + Answers = new { g.Key.AnswerText, Counter = g.Count() } }; - + //build the result List resultList = new List(); @@ -412,9 +468,9 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { var answers = from u in q.ToList() where u.RegionId.Equals(region.Id) - select u.Answers; - - resultList.Add(new { RegionId = region.Id, region.Name, region.Abbreviation, Answers = answers}); + select u.Answers; + + resultList.Add(new { RegionId = region.Id, region.Name, region.Abbreviation, Answers = answers }); } //return the object result return new { Regions = resultList }; @@ -470,13 +526,24 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get Survey Responses by surveyId - private async Task getSurveyResponsesBySurveyIdAsync(int surveyId) + private async Task getSurveyResponsesBySurveyIdAsync(int surveyId, int employeeid) { try { - var surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId).ToListAsync(); + List surveyResonses = null; + Employee employee = null; + List 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 questions = await questionServiceProvider.getQuestionsAsync(); 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 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 } - } - }; - return result; + if (employeeid == 0) + { + 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) { @@ -520,13 +625,31 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get All Survey Responses - private async Task getAllSurveyResponsesAsync() + private async Task getAllSurveyResponsesAsync(int employeeid) { try { - var surveyResonses = await surveyResponseDbContext.SurveyResponses.ToListAsync(); + List surveyResonses = null; + Employee employee = null; + List 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 questions = await questionServiceProvider.getQuestionsAsync(); var attachments = await attachmentServiceProvider.getAttachmentsAsync(); @@ -542,7 +665,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers r.KeyAnswerResult, r.Longitute, 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 where ans.SurveyResponseId == r.Id select new @@ -556,6 +679,8 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } }; return result; + + } catch (Exception ex) { @@ -566,11 +691,19 @@ namespace DamageAssesment.Api.SurveyResponses.Providers //Method to get Answers By Maintenance Center by surveyId - private async Task getResultsByMaintenanceCenterAsync(int surveyId) + private async Task getResultsByMaintenanceCenterAsync(int surveyId, int employeeid) { try { - var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId).ToListAsync(); + List 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 locations = await locationServiceProvider.getLocationsAsync(); var maintenanceCenters = locations.DistinctBy(m => m.MaintenanceCenter); @@ -601,7 +734,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers select new { g.Key.MaintenanceCenter, - Answers = new + Answers = new { g.Key.AnswerText, Counter = g.Count() @@ -626,13 +759,31 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } //Method to get Survey Responses by surveyId and LocationId - private async Task getSurveyResponsesBySurveyIdLocationIdAsync(int surveyId, int locationId) + private async Task getSurveyResponsesBySurveyIdLocationIdAsync(int surveyId, int locationId, int employeeid) { try { - var surveyResonses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == surveyId && x.LocationId.Equals(locationId)).ToListAsync(); + List surveyResonses = null; + Employee employee = null; + List 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 questions = await questionServiceProvider.getQuestionsAsync(); var surveyQuestions = from q in questions where q.SurveyId == surveyId select q; @@ -649,7 +800,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers r.KeyAnswerResult, r.Longitute, 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 where ans.SurveyResponseId == r.Id @@ -664,6 +815,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers } }; return result; + } catch (Exception ex) { @@ -674,13 +826,34 @@ 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) + private async Task getSurveyResponsesByAnswerAsync(Survey survey, Question question, string answer, int employeeid) { try { - var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.SurveyId == survey.Id).ToListAsync(); + List surveyResponses = null; + Employee employee = null; + List 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 employees = await employeeServiceProvider.getEmployeesAsync(); var attachments = await attachmentServiceProvider.getAttachmentsAsync(); var result = from r in surveyResponses @@ -694,7 +867,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers r.KeyAnswerResult, r.Longitute, 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 where ans.SurveyResponseId == r.Id && ans.QuestionId == question.Id @@ -757,7 +930,7 @@ namespace DamageAssesment.Api.SurveyResponses.Providers { 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) { var surveyResponse = response.SurveyResponse; diff --git a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs index c9df4db..19c081a 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.SurveyResponses/Services/SurveyServiceProvider.cs @@ -4,16 +4,18 @@ using Newtonsoft.Json; namespace DamageAssesment.Api.SurveyResponses.Services { - public class SurveyServiceProvider :ServiceProviderBase, ISurveyServiceProvider + public class SurveyServiceProvider : ServiceProviderBase, ISurveyServiceProvider { public SurveyServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger logger) : base(configuration, httpUtil, logger, configuration.GetValue("RessourceSettings:Survey"), configuration.GetValue("EndPointSettings:SurveyUrlBase")) { } - public async Task> getSurveysAsync() + public async Task> getSurveysAsync(string language) { try { + if (!string.IsNullOrEmpty(language)) + url = url + "/" + language; var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null); var surveys = JsonConvert.DeserializeObject>(responseJsonString); @@ -36,7 +38,7 @@ namespace DamageAssesment.Api.SurveyResponses.Services var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null); var survey = JsonConvert.DeserializeObject(responseJsonString); - if (survey == null ) + if (survey == null) return null; else return survey; } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs index 7853716..1821c2f 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Controllers/SurveysController.cs @@ -15,7 +15,6 @@ namespace DamageAssesment.Api.Surveys.Controllers /// /// GET request for retrieving surveys. /// - [Route("Surveys")] [Route("Surveys/{language:alpha}")] [HttpGet] @@ -47,7 +46,6 @@ namespace DamageAssesment.Api.Surveys.Controllers /// /// POST request for creating a new survey. /// - [HttpPost("Surveys")] public async Task PostSurveysAsync(Models.Survey survey) { @@ -61,8 +59,6 @@ namespace DamageAssesment.Api.Surveys.Controllers /// /// PUT request for updating an existing survey (surveyId,Updated Survey data). /// - - [HttpPut("Surveys/{id}")] public async Task PutSurveysAsync(int id, Models.Survey survey) { diff --git a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/DamageAssesment.Api.SurveyResponses.Test.csproj b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/DamageAssesment.Api.Responses.Test.csproj similarity index 95% rename from DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/DamageAssesment.Api.SurveyResponses.Test.csproj rename to DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/DamageAssesment.Api.Responses.Test.csproj index a384a67..03b9b5c 100644 --- a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/DamageAssesment.Api.SurveyResponses.Test.csproj +++ b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/DamageAssesment.Api.Responses.Test.csproj @@ -24,7 +24,7 @@ - + diff --git a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs index 47685a5..ffb8a4a 100644 --- a/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs +++ b/DamageAssesmentApi/DamageAssesment.SurveyResponses.Test/SurveyResponsesServiceTest.cs @@ -3,10 +3,9 @@ using DamageAssesment.Api.SurveyResponses.Interfaces; using DamageAssesment.Api.SurveyResponses.Models; using DamageAssesment.Api.SurveyResponses.Test; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore.Infrastructure; using Moq; using Xunit; -using Xunit.Sdk; + namespace DamageAssesment.SurveyResponses.Test { @@ -23,9 +22,9 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); 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 result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(); + var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); Assert.Equal(200, result.StatusCode); } @@ -33,9 +32,9 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode204() { 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 result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(); + var result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); Assert.Equal(400, result.StatusCode); } @@ -44,7 +43,7 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); 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 result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); Assert.Equal(200, result.StatusCode); @@ -54,7 +53,7 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode204() { 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 result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1); Assert.Equal(204, result.StatusCode); @@ -68,9 +67,9 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); 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 result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1); + var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1,1); Assert.Equal(200, result.StatusCode); } @@ -78,9 +77,9 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode204() { 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 result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1); + var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1, 1); Assert.Equal(204, result.StatusCode); } @@ -89,9 +88,9 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); 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 result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes"); + var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes",1); Assert.Equal(200, result.StatusCode); } @@ -99,9 +98,9 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode204() { 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 result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes"); + var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes",1); Assert.Equal(204, result.StatusCode); } @@ -111,9 +110,9 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); 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 result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1); + var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1, 1); Assert.Equal(200, result.StatusCode); } @@ -121,9 +120,9 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode204() { 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 result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1); + var result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1, 1); Assert.Equal(204, result.StatusCode); } @@ -132,9 +131,9 @@ namespace DamageAssesment.SurveyResponses.Test { SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject(); 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 result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1); + var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1, 1); Assert.Equal(200, result.StatusCode); } @@ -142,9 +141,9 @@ namespace DamageAssesment.SurveyResponses.Test public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode204() { 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 result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1); + var result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1, 1); Assert.Equal(204, result.StatusCode); } diff --git a/DamageAssesmentApi/DamageAssesment.sln b/DamageAssesmentApi/DamageAssesment.sln index 0cb2d7c..6c53f2d 100644 --- a/DamageAssesmentApi/DamageAssesment.sln +++ b/DamageAssesmentApi/DamageAssesment.sln @@ -17,13 +17,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations", "DamageAssesment.Api.Locations\DamageAssesment.Api.Locations.csproj", "{746C67BF-9949-4361-B5D2-358C7607750E}" 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 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Questions.Test", "DamageAssesment.Api.QuestionsTest\DamageAssesment.Api.Questions.Test.csproj", "{35CD9231-034D-4999-BCFC-1786DD007ED2}" 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}" 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 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