public ActionResult EditQuestion(int id) { BePreferencesEntities db = new BePreferencesEntities(); InkeyAnswer answerToEdit = db.InkeyAnswers.FirstOrDefault(i => i.InkeyAnswersId == id); //answerToEdit.ProductName = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == (int)answerToEdit.ProductId).ProductName; return(View(db.InkeyAnswers.FirstOrDefault(i => i.InkeyAnswersId == id))); }
public ActionResult EditQuestion(InkeyAnswer inkAnswer) { try { using (var db = new BePreferencesEntities()) { inkAnswer.ProductName = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == inkAnswer.ProductId).ProductName; db.Entry(inkAnswer).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("InkeyAnswerForm")); } catch (Exception) { throw; } }
public ActionResult InkeyAnswerForm(InkeyViewModel inkMod) { try { InkeyAnswer newAns = inkMod.answer; using (var db = new BePreferencesEntities()) { newAns.ProductName = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == inkMod.answer.ProductId).ProductName; db.InkeyAnswers.Add(newAns); db.SaveChanges(); return(View(new InkeyViewModel())); } } catch (Exception ex) { throw ex; } }
public InkeyViewModel() { answer = new InkeyAnswer(); InkeyAnswers = db.InkeyAnswers.ToList(); InkeyJsonAnswers = JsonConvert.SerializeObject(db.InkeyAnswers.ToArray()); }
public ActionResult SummerNote(InkeyAnswer inkAns) { return(View(inkAns)); }
public ActionResult SummerNote() { InkeyAnswer inkAns = new InkeyAnswer(); return(View(inkAns)); }