package com.realnet.badmintoncourt.Controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.realnet.config.EmailService;
import com.realnet.users.entity1.AppUser;
import com.realnet.users.service1.AppUserServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.data.domain.*;
import com.realnet.fnd.response.EntityResponse;
import org.springframework.http.*;
import org.springframework.beans.factory.annotation.*;
import com.realnet.badmintoncourt.Entity.Badminton_court;
import com.realnet.badmintoncourt.Services.Badminton_courtService ;






@RequestMapping(value = "/token/Badminton_court")
 @CrossOrigin("*") 
@RestController
public class tokenFree_Badminton_courtController {
	@Autowired
	private Badminton_courtService Service;

@Value("${projectPath}")
	private String projectPath;
 






	@PostMapping("/Badminton_court")
		  public Badminton_court Savedata(@RequestBody Badminton_court data) {
		Badminton_court save = Service.Savedata(data)	;





		System.out.println("data saved..." + save);

 return save;
	  }
@PutMapping("/Badminton_court/{id}")
	public  Badminton_court update(@RequestBody Badminton_court data,@PathVariable Integer id ) {
		Badminton_court update = Service.update(data,id);
		System.out.println("data update..." + update);
		return update;
	}	 
//	get all with pagination
	@GetMapping("/Badminton_court/getall/page")
	public Page<Badminton_court> getall(@RequestParam(value = "page", required = false) Integer page,
			@RequestParam(value = "size", required = false) Integer size) {
		Pageable paging = PageRequest.of(page, size);
		Page<Badminton_court> get = Service.getAllWithPagination(paging);

		return get;

	}	
	@GetMapping("/Badminton_court")
	public List<Badminton_court> getdetails() {
		 List<Badminton_court> get = Service.getdetails();		
		return get;
}
// get all without authentication 

	@GetMapping("/token/Badminton_court")
	public List<Badminton_court> getallwioutsec() {
		 List<Badminton_court> get = Service.getdetails();		
		return get;
}
@GetMapping("/Badminton_court/{id}")
	public  Badminton_court  getdetailsbyId(@PathVariable Integer id ) {
		Badminton_court  get = Service.getdetailsbyId(id);
		return get;
	}
@DeleteMapping("/Badminton_court/{id}")
	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
	Service.delete_by_id(id);
			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
	
	}







}