Esempio n. 1
0
        public async Task <IActionResult> Confirm(ConfirmationResult confirmation)
        {
            if (confirmation == null || confirmation.UniqueId == null)
            {
                return(NotFound());
            }

            var candidate = await _context.Candidates
                            .SingleOrDefaultAsync(m => m.Guid == confirmation.UniqueId);

            if (candidate == null)
            {
                return(NotFound("We could not find the candidate you were looking for. If you were trying to submit your confirmation page and it did not work, please message us on Facebook."));
            }

            candidate.Confirmed = true;
            candidate.Accepted  = confirmation.Accepted;

            _context.Update(candidate);
            await _context.SaveChangesAsync();

            var result = "Thank you for submitting your response.";

            if (confirmation.Accepted)
            {
                result += "Your response has been noted and you are now eligible to be seconded.";
            }
            else
            {
                result += "Your response has been noted and you will be removed from the candidates list.";
            }

            return(Ok(result));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Center,Address")] Circuit circuit)
        {
            if (id != circuit.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(circuit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CircuitExists(circuit.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(circuit));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Content,Type,Submitter,SubmitterEmail,Id")] Comment comment)
        {
            if (id != comment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentExists(comment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(comment));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Email,Code,Id")] Voter voter)
        {
            if (id != voter.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(voter);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VoterExists(voter.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(voter));
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address,CircuitId")] District district)
        {
            if (id != district.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(district);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DistrictExists(district.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CircuitId"] = new SelectList(_context.Circuit, "Id", "Address", district.CircuitId);
            return(View(district));
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Year,Tour, StartDate, EndDate, HeadOfCvk")] Election election)
        {
            if (id != election.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(election);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ElectionExists(election.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(election));
        }