public async Task <IActionResult> PostNewSurvey(SurveyViewModel survey) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } // Convert SurveyViewModel to Survey Survey surveyEnt = survey.ConvertToSurvey(); bool added = await surveyContext.AddSurvey(surveyEnt); if (added) { return(CreatedAtAction("PostNewSurvey", "Survey Added Successfully")); } else { return(BadRequest("Error occured while saving the Survey.")); } }
//SurveyDAL public void AddSurvey(surveys survey) { surveyDAL.AddSurvey(survey); }