コード例 #1
0
ファイル: SurveyController.cs プロジェクト: tdalia/NetTechno
        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."));
            }
        }