public async Task <IActionResult> PostNewEmpSurvey(SurveyViewModel survey) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } // Convert SurveyViewModel to Survey Survey surveyEnt = survey.ConvertToSurvey(); surveyEnt.Employee = employeeContext.GetEmployee((int)survey.EmployeeId); bool added = await surveyContext.AddEmpSurvey(surveyEnt); // Update Emp Rating ( if (added) { return(CreatedAtAction("PostNewEmpSurvey", "Survey Added Successfully")); } else { return(BadRequest("Error occured while saving the Survey.")); } }