public async Task <IActionResult> CommentSubmission(Comment comment, [FromRoute(Name = "id")] int?id) { if (id == null) { return(NotFound()); } var candidate = await _context.Candidates .SingleOrDefaultAsync(m => m.Id == id); if (candidate == null) { return(NotFound()); } if (comment == null) { return(BadRequest("Problem with submitting comment. Please message us to get this resolved ASAP.")); } comment.Id = 0; comment.Candidate = candidate; _context.Add(comment); await _context.SaveChangesAsync(); if (candidate.State == CandidateState.Accepted && comment.Type == Models.Comment.CommentType.Positive) { candidate.Ready = true; } await _context.SaveChangesAsync(); return(Json(comment)); }
public async Task <IActionResult> Create([Bind("Id,Name,Center,Address")] Circuit circuit) { if (ModelState.IsValid) { _context.Add(circuit); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(circuit)); }
public async Task <IActionResult> Create([Bind("Content,Type,Submitter,SubmitterEmail,Id")] Comment comment) { if (ModelState.IsValid) { _context.Add(comment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(comment)); }
public async Task <IActionResult> Create([Bind("Id,Name,Year,Tour, StartDate, EndDate, HeadOfCvk")] Election election) { if (ModelState.IsValid) { _context.Add(election); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(election)); }
public async Task <IActionResult> Create([Bind("For,Id")] Vote vote) { if (ModelState.IsValid) { _context.Add(vote); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vote)); }
public async Task <IActionResult> Create([Bind("Name,Email,Code,Id")] Voter voter) { if (ModelState.IsValid) { _context.Add(voter); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(voter)); //System.Security.Cryptography.MD5.Create().ComputeHash(System.Text.Encoding.ASCII.GetBytes("f36145e13e32ab59ac0304cf3d2f1994")); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,CircuitId")] District district) { if (ModelState.IsValid) { _context.Add(district); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CircuitId"] = new SelectList(_context.Circuit, "Id", "Address", district.CircuitId); return(View(district)); }
public async Task <IActionResult> Create(Candidate candidate) { candidate.Guid = System.Guid.NewGuid(); if (ModelState.IsValid) { _context.Add(candidate); await _context.SaveChangesAsync(); _mailer.SendCandidateConfirmation(candidate); return(Redirect("/Candidates")); } return(RedirectToAction(nameof(Nominate))); }
public async Task <IActionResult> SignUp([FromForm] string email) { email = email.Trim(); if (_context.Voters.Any(x => x.Email == email)) { return(Ok("You've already signed up")); } var code = email.MD5(); var voter = new Voter { Email = email, Code = code }; _context.Add(voter); await _context.SaveChangesAsync(); return(Ok(_mailer.SendConfirmationMail(email, code))); }