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