package com.documents.controllers;

import com.documents.models.Secretary;
import com.documents.services.SecretaryService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Georgiana&Ecaterina on 07.05.2017.
 */

@RestController
public class SecretaryController {

    @Autowired
    private SecretaryService studentService;

    @RequestMapping(value = "/secretary/{id}", method = RequestMethod.GET)
    public ResponseEntity<Secretary> searchStudentById(@PathVariable Long id) {
        Secretary secretary = studentService.findById(id);
        if (secretary != null) {
            return new ResponseEntity<Secretary>(secretary, HttpStatus.OK);
        } else {
            return new ResponseEntity<Secretary>(HttpStatus.NOT_FOUND);
        }
    }
}

@@ -333,16 +333,76 @@
 riable;%0A
+import org.springframework.web.bind.annotation.RequestBody;%0A
 import o
@@ -456,16 +456,16 @@
 apping;%0A
-
 import o
@@ -639,17 +639,16 @@
 17.%0A */%0A
-%0A
 @RestCon
@@ -655,16 +655,55 @@
 troller%0A
+@RequestMapping(value = %22/secretary%22)%0A%0A
 public c
@@ -775,22 +775,24 @@
 ervice s
-tudent
+ecretary
 Service;
@@ -979,22 +979,24 @@
 tary = s
-tudent
+ecretary
 Service.
@@ -1207,16 +1207,16 @@
 FOUND);%0A
-
         
@@ -1222,11 +1222,2048 @@
  %7D%0A    %7D
+%0A%0A    /**%0A     * Delete a specific secretary from database%0A     *%0A     * @param id of the secretary you want to delete it%0A     *%0A     * @return - a status if the student with that id was delete it or not%0A     */%0A    @RequestMapping(value = %22/%7Bid%7D%22, method = RequestMethod.DELETE)%0A    public ResponseEntity%3CSecretary%3E deleteSecretary(@PathVariable Long id) %7B%0A        Secretary secretary = secretaryService.findById(id);%0A        if (secretary != null) %7B%0A            secretaryService.delete(id);%0A        %7D else %7B%0A            return new ResponseEntity%3CSecretary%3E(HttpStatus.NO_CONTENT);%0A        %7D%0A        return new ResponseEntity%3CSecretary%3E(HttpStatus.OK);%0A    %7D%0A%0A    /**%0A     * Insert a new secretary into the database%0A     *%0A     * @param newSecretary - a new Secretary object that you want to insert into the database%0A     *%0A     * @return - the newSecretary inserted plus a status if was successfully inserted%0A     */%0A%0A    @RequestMapping(value = %22/secretary%22, method = RequestMethod.POST)%0A    public ResponseEntity%3CSecretary%3E createSecretary(@RequestBody Secretary newSecretary) %7B%0A        Secretary savedSecretary = secretaryService.save(newSecretary);%0A        return new ResponseEntity%3CSecretary%3E(savedSecretary, HttpStatus.CREATED);%0A    %7D%0A%0A    /**%0A     * Update a secretary data(change his information in database)%0A     *%0A     * @param secretary - a new Secretary Object%0A     * @param id - the id of the secretary where you want to insert new data%0A     *  You save into the database the changed secretary object%0A     * @return return a status if was successfully updated%0A     */%0A%0A    @RequestMapping(value = %22/%7Bid%7D%22, method = RequestMethod.PUT)%0A    public ResponseEntity%3CSecretary%3E updateSecretary(@RequestBody Secretary secretary, @PathVariable Long id) %7B%0A        if (!id.equals(secretary.getId())) %7B%0A            return new ResponseEntity%3CSecretary%3E(HttpStatus.BAD_REQUEST);%0A        %7D%0A        Secretary newSecretary = secretaryService.save(secretary);%0A        return new ResponseEntity%3CSecretary%3E(newSecretary, HttpStatus.OK);%0A    %7D
 %0A%7D%0A

update Controller