public ActionResult Create(FormCollection collection, string[] answers) { var vote = new Vote(); try { // TODO: Add insert logic here UpdateModel( vote ); vote.created_at = DateTime.UtcNow; vote.question_name = Request.Form["question_name"]; vote.question_text = Request.Form["question_text"]; vote.status = 0; vote.is_pinned = false; vote.created_by = voteRepository.GetUserId( User.Identity.Name ); var voteId = voteRepository.AddVote( vote ); var orderN = 1; foreach (var answer in answers) { if (String.IsNullOrEmpty( answer )) continue; var voteAnswer = new VoteAnswer(); voteAnswer.answer_text = answer; voteAnswer.vote_id = voteId; voteAnswer.order_n = orderN; voteRepository.AddVoteAnswer( voteAnswer ); orderN++; } return RedirectToAction("Index"); } catch { return View(); } }
private void detach_VoteAnswers(VoteAnswer entity) { this.SendPropertyChanging(); entity.Vote = null; }
public ActionResult Edit(int id, FormCollection collection, string[] answers ) { try { // TODO: Add update logic here //vote.question_name = Request.Form["question_name"]; //vote.question_text = Request.Form["questiont_text"]; var vote = voteRepository.GetVote( id ); UpdateModel( vote ); voteRepository.Save(); voteRepository.RemoveAnswers( id ); var orderN = 1; foreach (var answer in answers) { if (String.IsNullOrEmpty( answer )) continue; var voteAnswer = new VoteAnswer(); voteAnswer.answer_text = answer; voteAnswer.vote_id = id; voteAnswer.order_n = orderN; voteRepository.AddVoteAnswer( voteAnswer ); orderN++; } voteRepository.Save(); return RedirectToAction("Index"); } catch { return RedirectToAction( "Index" ); } }
private void attach_VoteAnswers(VoteAnswer entity) { this.SendPropertyChanging(); entity.Vote = this; }
partial void DeleteVoteAnswer(VoteAnswer instance);
partial void UpdateVoteAnswer(VoteAnswer instance);
partial void InsertVoteAnswer(VoteAnswer instance);
public void AddVoteAnswer( VoteAnswer voteAnswer ) { _db.VoteAnswers.InsertOnSubmit( voteAnswer ); Save(); }