package arnelid.bjorn.redo.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import arnelid.bjorn.redo.model.Family;
import arnelid.bjorn.redo.repository.FamilyRepository;


@RestController
public class FamilyController {
	@Autowired
	FamilyRepository familyRepository;
	
	
	@GetMapping("/{name}")
	Family getFamily(@PathVariable String name) {
		return familyRepository.findByName(name);
	}
	
	@PostMapping(path = "/Family", consumes = MediaType.APPLICATION_JSON_VALUE)
	void postFamily(@RequestBody Family newFamily) {
		familyRepository.save(newFamily);
	}
}

@@ -133,16 +133,78 @@
 iaType;%0A
+import org.springframework.web.bind.annotation.DeleteMapping;%0A
 import o
@@ -697,15 +697,15 @@
 y;%0A%09
-%0A
 %09%0A%09@
-Ge
+Pos
 tMap
@@ -713,32 +713,203 @@
 ing(
-%22/%7Bname%7D%22)%0A%09Family getFa
+path = %22/family%22, consumes = MediaType.APPLICATION_JSON_VALUE)%0A%09void postFamily(@RequestBody Family newFamily) %7B%0A%09%09familyRepository.save(newFamily);%0A%09%7D%0A%09%0A%09@DeleteMapping(%22/%7Bname%7D%22)%0A%09void deleteFA
 mily
@@ -944,14 +944,28 @@
 %7B%0A%09%09
-return
+Family toBeDeleted =
  fam
@@ -1001,141 +1001,131 @@
 );%0A%09
-%7D%0A%09%0A%09@PostMapping(path = %22/Family%22, consumes = MediaType.APPLICATION_JSON_VALUE)%0A%09void postFamily(@RequestBody Family newFamily) %7B%0A%09%09
+%09familyRepository.delete(toBeDeleted);%0A%09%7D%0A%0A%09@GetMapping(%22/%7Bname%7D%22)%0A%09Family getFamily(@PathVariable String name) %7B%0A%09%09return 
 fami
@@ -1133,34 +1133,35 @@
 yRepository.
-save(newFamily
+findByName(name
 );%0A%09%7D%0A%7D%0A

Add delete mapping for family.