错误在 Create() 函数中
创造()
错误 1 'MvcAnketaIT.Controllers.SurveyController.Create()':并非所有代码路径都返回值
代码
public ActionResult Create()
{
int myId = getIdByUser(this.User.Identity.Name);
if (this.User.Identity.IsAuthenticated)
{
if (myId == -1) //no questionnaire in db
{
SurveyModel survey = new SurveyModel();
ViewBag.userName = this.User.Identity.Name;
ViewBag.Q3Sex = new SelectList(db.Genders, "ID", "gender");
ViewBag.Q8Question1 = new SelectList(db.Questions1, "Id", "Technology");
ViewBag.Q9Question2_1 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q10Question2_2 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q11Question2_3 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q12Question2_4 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q13Question2_5 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q14Question2_6 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q15Question2_7 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q16Question2_8 = new SelectList(db.Satisfaction, "ID", "Name");
ViewBag.Q17Question3 = new SelectList(db.Questions3, "ID", "Solve");
ViewBag.Q19Question5 = new SelectList(db.Questions5, "ID", "No_Contacts");
ViewBag.Q20Question6 = new SelectList(db.Questions6, "ID", "Recommendation");
return View();
}
}
else //user already has a questionnaire fulfilled
{
return RedirectToAction("Edit/" + myId); //redirect to the right id of the user
}
}