Check isFullDay
This commit is contained in:
parent
2918bc46b5
commit
609c0353d0
@ -160,6 +160,22 @@ public class EventController {
|
|||||||
userEvent.setEvent(event);
|
userEvent.setEvent(event);
|
||||||
userEvent.setUser(user);
|
userEvent.setUser(user);
|
||||||
|
|
||||||
|
List<UserEvent> userEvents = userEventRepository.findByUserIdAndDate(user.getId(), userEvent.getDate());
|
||||||
|
System.out.println(userEvents.size() + "");
|
||||||
|
if(event.isFullDay() && userEvents.size() > 0){
|
||||||
|
return new ResponseEntity<>("Es gibt bereits Termine am " + userEvent.getDate(), HttpStatus.BAD_REQUEST);
|
||||||
|
}else{
|
||||||
|
for(UserEvent ue : userEvents){
|
||||||
|
if(ue.getEvent().isFullDay()){
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
"Der Tag " + userEvent.getDate() + " ist schon mit '"
|
||||||
|
+ ue.getEvent().getName() + "' belegt",
|
||||||
|
HttpStatus.BAD_REQUEST
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eventRepository.save(event);
|
eventRepository.save(event);
|
||||||
userEventRepository.save(userEvent);
|
userEventRepository.save(userEvent);
|
||||||
}catch (IllegalArgumentException exception){
|
}catch (IllegalArgumentException exception){
|
||||||
|
@ -3,9 +3,12 @@ package com.vpr.server.repository;
|
|||||||
import com.vpr.server.data.UserEvent;
|
import com.vpr.server.data.UserEvent;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
// This will be AUTO IMPLEMENTED by Spring into a Bean called eventListRepository
|
// This will be AUTO IMPLEMENTED by Spring into a Bean called eventListRepository
|
||||||
// CRUD refers Create, Read, Update, Delete
|
// CRUD refers Create, Read, Update, Delete
|
||||||
|
|
||||||
public interface UserEventRepository extends CrudRepository<UserEvent, Integer> {
|
public interface UserEventRepository extends CrudRepository<UserEvent, Integer> {
|
||||||
|
List<UserEvent> findByUserIdAndDate(long userId, Date date);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user