@RequestMapping(value = "/updateYearMaster", method = RequestMethod.POST)
public String updateYearmaster(@RequestParam(value = "id", required = false) Long id,
@RequestParam(value = "fromyear", required = false) Date fromyear,
@RequestParam(value = "toyear", required = false) Date toyear,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "yeardescription", required = false) String yeardescription, Model model) {
Yearmaster yearmaster = new Yearmaster(fromyear, toyear, status, yeardescription);
yearmaster.setId(id);
List val = yearmasterService.duplicateEditYear(fromyear, toyear, id);
if (!val.isEmpty()) {
model.addAttribute("yearmaster", yearmaster);
errorMessage = "fromyear and toyear combination is already exist";
model.addAttribute("errorMessage", errorMessage);
return "edit-year-master";
} else {
yearmasterService.save(yearmaster);
return "redirect:/yearmaster";
}
}