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_Votes(Vote entity)
		{
			this.SendPropertyChanging();
			entity.VoteUser = null;
		}
Exemplo n.º 3
0
 public ActionResult Create()
 {
     var vote = new Vote();
     return View( vote );
 }
Exemplo n.º 4
0
		private void attach_Votes(Vote entity)
		{
			this.SendPropertyChanging();
			entity.VoteUser = this;
		}
Exemplo n.º 5
0
 partial void DeleteVote(Vote instance);
Exemplo n.º 6
0
 partial void UpdateVote(Vote instance);
Exemplo n.º 7
0
 partial void InsertVote(Vote instance);
Exemplo n.º 8
0
 public Int64 AddVote( Vote vote )
 {
     _db.Votes.InsertOnSubmit( vote );
     Save();
     return GetLastVoteId();
 }