public async Task <IActionResult> PutCandidate(long id, Candidate candidate) { if (id != candidate.CandidateId) { return(BadRequest()); } _context.Entry(candidate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!CandidateExists(id)) { if (!CandidateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMemberOfParliament(long id, MemberOfParliament memberOfParliament) { if (id != memberOfParliament.ConstituencyId) { return(BadRequest()); } _context.Entry(memberOfParliament).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MemberOfParliamentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutElection(long id, ElectionDTO electionDTO) { if (id != electionDTO.ElectionId) { return(BadRequest()); } var election = await _context.Elections.FindAsync(id); if (election == null) { return(NotFound()); } election.ElectionType = electionDTO.ElectionType; election.ElectionDate = electionDTO.ElectionDate; _context.Entry(election).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!ElectionExists(id)) { return(NotFound()); } return(NoContent()); }
public async Task <IActionResult> PutVoter(long id, Voter voter) { if (id != voter.VoterId) { return(BadRequest()); } _context.Entry(voter).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VoterExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPollingStation(long id, PollingStation pollingStation) { if (id != pollingStation.StationId) { return(BadRequest()); } _context.Entry(pollingStation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PollingStationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutConstituency(long id, Constituency constituency) { if (id != constituency.ConstituencyId) { return(BadRequest()); } _context.Entry(constituency).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConstituencyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMember(long id, MemberDTO memberDTO) { if (id != memberDTO.MemberId) { return(BadRequest()); } var member = await _context.Members.FindAsync(id); if (member == null) { return(NotFound()); } member.Photo = memberDTO.Photo; member.Prefix = memberDTO.Prefix; member.FirstName = memberDTO.FirstName; member.MiddleName = memberDTO.MiddleName; member.LastName = memberDTO.LastName; member.Position = memberDTO.Position; member.PartyId = memberDTO.PartyId; member.Telephone = memberDTO.Telephone; member.Address = memberDTO.Address; _context.Entry(member).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!MemberExists(id)) { return(NotFound()); } return(NoContent()); }