added survey start and end date validation

This commit is contained in:
Vijay Uppu 2023-12-13 17:08:59 -05:00
parent 9188ded00e
commit 1c26852670

View File

@ -179,6 +179,11 @@ namespace DamageAssesment.Api.Surveys.Providers
{ {
if (survey != null) 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; survey.CreatedDate = DateTime.Now;
Db.Survey _survey = mapper.Map<Models.Survey, Db.Survey>(survey); Db.Survey _survey = mapper.Map<Models.Survey, Db.Survey>(survey);
@ -215,6 +220,11 @@ namespace DamageAssesment.Api.Surveys.Providers
{ {
if (survey != null) 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(); var _survey = await surveyDbContext.Surveys.AsNoTracking().Where(s => s.Id == Id).SingleOrDefaultAsync();
if (_survey != null) if (_survey != null)