Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public ResultsController(ResultService resultService) {

@GetMapping("/result/{id}")
ConstituencyResult getResult(@PathVariable Integer id) {
ConstituencyResult result = resultService.GetResult(id);
ConstituencyResult result = resultService.getResult(id);
if (result == null) {
throw new ResultNotFoundException(id);
}
return resultService.GetResult(id);
return result;
}

@PostMapping("/result")
ResponseEntity<String> newResult(@RequestBody ConstituencyResult result) {
if (result.getId() != null) {
resultService.NewResult(result);
resultService.newResult(result);
return ResponseEntity.created(URI.create("/result/"+result.getId())).build();
}
return ResponseEntity.badRequest().body("Id was null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public MapBasedRepository() {
}

@Override
public ConstituencyResult GetResult(Integer id) {
public ConstituencyResult getResult(Integer id) {
return results.get(id);
}

@Override
public void NewResult(ConstituencyResult result) {
public void newResult(ConstituencyResult result) {
results.put(result.getId(), result);
}

@Override
public Map<Integer, ConstituencyResult> GetAll() {
public Map<Integer, ConstituencyResult> getAll() {
return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import bbc.news.elections.model.ConstituencyResult;

import java.util.List;
import java.util.Map;

public interface ResultService {
ConstituencyResult GetResult(Integer id);
void NewResult(ConstituencyResult result);
Map<Integer,ConstituencyResult> GetAll();
ConstituencyResult getResult(Integer id);
void newResult(ConstituencyResult result);
Map<Integer,ConstituencyResult> getAll();
void reset();
}