示例#1
0
 public ActionResult Create(Survey survey)
 {
     if (ModelState.IsValid)
       {
     surveyRepository.InsertOrUpdate(survey);
     surveyRepository.Save();
     return RedirectToAction("Index");
       }
       return View(survey);
 }
示例#2
0
 public void InsertOrUpdate(Survey survey)
 {
     if (survey.Id == default(int))
       {
     // New entity
     context.Surveys.Add(survey);
       }
       else
       {
     // Existing entity
     context.Entry(survey).State = EntityState.Modified;
       }
 }