Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
		private void detach_VoteAnswers(VoteAnswer entity)
		{
			this.SendPropertyChanging();
			entity.Vote = null;
		}
Exemplo n.º 3
0
        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" );
            }
        }
Exemplo n.º 4
0
		private void attach_VoteAnswers(VoteAnswer entity)
		{
			this.SendPropertyChanging();
			entity.Vote = this;
		}
Exemplo n.º 5
0
 partial void DeleteVoteAnswer(VoteAnswer instance);
Exemplo n.º 6
0
 partial void UpdateVoteAnswer(VoteAnswer instance);
Exemplo n.º 7
0
 partial void InsertVoteAnswer(VoteAnswer instance);
Exemplo n.º 8
0
 public void AddVoteAnswer( VoteAnswer voteAnswer )
 {
     _db.VoteAnswers.InsertOnSubmit( voteAnswer );
     Save();
 }