コード例 #1
0
        public ActionResult Create(CandidateViewModel candidateViewModel)
        {
            try
            {
                var candidate = new Candidate {
                    FirstName = candidateViewModel.FirstName,
                    Id        = candidateViewModel.Id,
                    LastName  = candidateViewModel.LastName,
                    PartyName = candidateViewModel.PartyName
                };
                ApiConsumer <Candidate> .ConsumePost("Candidates", candidate);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #2
0
        public ActionResult Create(VoterViewModel voterViewModel)
        {
            try
            {
                var voter = new Voter
                {
                    FirstName       = voterViewModel.FirstName,
                    Id              = voterViewModel.Id,
                    LastName        = voterViewModel.LastName,
                    Cnp             = voterViewModel.Cnp,
                    SecretQuestions = new List <SecretQuestion>()
                };
                var taskResult = ApiConsumer <Voter> .ConsumePost("Voters", voter);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }