Commit d9d6899a authored by s7_spruge_k's avatar s7_spruge_k
Browse files

basic view event controllers done + basic views

parent b3f0c42d
......@@ -111,7 +111,14 @@ public class EventController {
// Calendar currCal = calendarRepo.findAllByUser(currUser).get(currUser.getActiveCalendar());
try
{
Event currEvent = eventRepo.findById(eventID).get();
}
catch(Exception e)
{
return "redirect:/calendar";
}
Event currEvent = eventRepo.findById(eventID).get();
models.addAttribute("currentEvent", currEvent);
......@@ -137,6 +144,15 @@ public class EventController {
@GetMapping(value = "view-event-edit/{id}")
public String viewEventEditGet(Event event, Model models, @PathVariable (name = "id") int eventID)
{
try
{
Event currEvent = eventRepo.findById(eventID).get();
}
catch(Exception e)
{
return "redirect:/calendar";
}
Event currEvent = eventRepo.findById(eventID).get();
models.addAttribute("currentEvent", currEvent);
......@@ -189,7 +205,17 @@ public class EventController {
@GetMapping(value = "/delete-event/{id}")
public String deleteEventGet(Model models, @PathVariable (name = "id") int eventID)
{
eventRepo.deleteById(eventID);
try
{
//Vai izpildaas, ja ir try blokā??????
eventRepo.deleteById(eventID);
}
catch(Exception e)
{
return "redirect:/calendar";
}
//eventRepo.deleteById(eventID);
return "redirect:/calendar";
}
......
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Event view</title>
</head>
<h2>Event view</h2>
<body>
</body>
</html>
\ No newline at end of file
<Head><title>View event</title></Head>
<body>
<h2>View event</h2>
<table>
<tr>
<td th:text = "'currentEvent: | ' + ${currentEvent.getName()}"/>
<td th:text = "'Desc: ' + ${currentEvent.getDescription()}"/>
<td th:text = "${currentEvent.getStartDate()}"/>
<td th:text = "${currentEvent.getStartTime()}"/>
<td th:text = "${currentEvent.getIsAllDayEvent()}"/>
<td th:text = "${currentEvent.getCalendar().getName()}"/>
</table>
<button type="button">Edit</button>
<button type="button">Delete</button>
<button type="button">Return</button>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<Head><title>View event (edit mode)</title></Head>
<body>
<h2>View event (edit mode)</h2>
<table>
<tr>
<td th:text = "'currentEvent: | ' + ${currentEvent.getName()}"/>
<td th:text = "'Desc: ' + ${currentEvent.getDescription()}"/>
<td th:text = "${currentEvent.getStartDate()}"/>
<td th:text = "${currentEvent.getStartTime()}"/>
<td th:text = "${currentEvent.getIsAllDayEvent()}"/>
<td th:text = "${currentEvent.getCalendar().getName()}"/>
</table>
<button type="button">Save</button>
<button type="button">Return</button>
<button type="button">Delete</button>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment