Example #1
0
        public static bool SavePollVoteForm(PollVoteFormModel model)
        {
            spiffaiwebEntities db = new spiffaiwebEntities();
            bool success =false;
            try
            {
                //Save PollVote
                var voteModel = new PollVote
                {
                    PollId = model.PollId,
                    PollOptionId = (int)model.SelectedPollOptionId,
                    UserId = (int)WebSecurity.CurrentUserId,
                    VoteDate = (DateTime)DateTime.Now
                };

                db.PollVotes.Add(voteModel);
                db.SaveChanges();

                success = SavePollVoteCount(model.PollId, voteModel.PollOptionId);
            }
            catch (Exception ex)
            {
                throw;
            }
            return success;
        }
Example #2
0
        public static PollVoteFormModel GetVoteForm(int pollId)
	    {
            spiffaiwebEntities db = LoadDB();
            var poll = (from p in db.Polls where p.PollId == pollId select p).FirstOrDefault();
            var optionsList = GetPollOptions(pollId);

	        var result = new PollVoteFormModel
	        {
                PollId = poll.PollId,
                PollTitle = poll.PollTitle,
                PollDetails = poll.PollDetails,
                Deadline = poll.Deadline,
                IsActive = poll.IsActive,
                Options = optionsList
	        };
            return result;
	    }
 public ActionResult SaveTeamPollVoteForm(PollVoteFormModel model)
 {
     //Action to Save Vote Form
     if (ModelState.IsValid)
     {
         var response = DAL.SavePollVoteForm(model);
         return Json(new { Success = true });
     }
     return Json(new { Success = false });
 }