Exemplo n.º 1
0
 public ActionResult Create(Response response)
 {
     if (ModelState.IsValid) {
         responseRepository.InsertOrUpdate(response);
         responseRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
Exemplo n.º 2
0
 public void InsertOrUpdate(Response response)
 {
     if (response.Id == default(int)) {
         // New entity
         context.Responses.Add(response);
     } else {
         // Existing entity
         context.Responses.Attach(response);
         context.Entry(response).State = EntityState.Modified;
     }
 }