From 86dea1b9425141881abf8d3d4a6eb6db15a436a9 Mon Sep 17 00:00:00 2001 From: Vijay Uppu <913468@dadeschools.net> Date: Wed, 13 Dec 2023 17:15:40 -0500 Subject: [PATCH] added survey start and end date validation --- .../Providers/SurveysProvider.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Providers/SurveysProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Providers/SurveysProvider.cs index 3a2e81c..4fd2f20 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Surveys/Providers/SurveysProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Surveys/Providers/SurveysProvider.cs @@ -179,6 +179,11 @@ namespace DamageAssesment.Api.Surveys.Providers { if (survey != null) { + if (survey.StartDate != null && survey.EndDate != null) + { + if(survey.StartDate.Value>survey.EndDate.Value) + return (false, null, $"Survey start date should be less than enddate"); + } survey.CreatedDate = DateTime.Now; Db.Survey _survey = mapper.Map(survey); @@ -215,6 +220,11 @@ namespace DamageAssesment.Api.Surveys.Providers { if (survey != null) { + if (survey.StartDate != null && survey.EndDate != null) + { + if (survey.StartDate.Value > survey.EndDate.Value) + return (false, null, $"Survey start date should be less than enddate"); + } var _survey = await surveyDbContext.Surveys.AsNoTracking().Where(s => s.Id == Id).SingleOrDefaultAsync(); if (_survey != null)