Index: src/main/java/com/example/rezevirajmasa/demo/component/ReservationScheduler.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/component/ReservationScheduler.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/component/ReservationScheduler.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,2 +1,20 @@
-package com.example.rezevirajmasa.demo.component;public class ReservationScheduler {
+package com.example.rezevirajmasa.demo.component;
+
+import com.example.rezevirajmasa.demo.service.ReservationService;
+import jakarta.annotation.PostConstruct;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ReservationScheduler {
+    private final ReservationService reservationService;
+
+    public ReservationScheduler(ReservationService reservationService) {
+        this.reservationService = reservationService;
+    }
+
+    @PostConstruct
+    void runOnStartup() {
+        reservationService.findReservationsToMove();
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/config/ModelMapperConfig.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/config/ModelMapperConfig.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/config/ModelMapperConfig.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,2 +1,34 @@
-package com.example.rezevirajmasa.demo.config;public class ModelMapperConfig {
+package com.example.rezevirajmasa.demo.config;
+
+import com.example.rezevirajmasa.demo.dto.ReservationDTO;
+import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
+import com.example.rezevirajmasa.demo.dto.TableDTO;
+import com.example.rezevirajmasa.demo.model.Reservation;
+import com.example.rezevirajmasa.demo.model.Restaurant;
+import com.example.rezevirajmasa.demo.model.TableEntity;
+import org.modelmapper.ModelMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ModelMapperConfig {
+    @Bean
+    public ModelMapper modelMapper() {
+        ModelMapper modelMapper = new ModelMapper();
+
+        // Map Restaurant to RestaurantDTO
+        modelMapper.typeMap(Restaurant.class, RestaurantDTO.class).addMappings(mapper -> {
+            mapper.map(Restaurant::getTablesList, RestaurantDTO::setTablesList);
+        });
+
+        // Map TableEntity to TableDTO
+        modelMapper.typeMap(TableEntity.class, TableDTO.class).addMappings(mapper -> {
+            mapper.map(TableEntity::getReservations, TableDTO::setReservations);
+        });
+
+        // Map Reservation to ReservationDTO
+        modelMapper.typeMap(Reservation.class, ReservationDTO.class);
+
+        return modelMapper;
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/config/RestExceptionHandler.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/config/RestExceptionHandler.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/config/RestExceptionHandler.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -3,5 +3,7 @@
 import com.example.rezevirajmasa.demo.dto.ErrorDto;
 import com.example.rezevirajmasa.demo.model.exceptions.AppException;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.HttpMessageNotWritableException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -16,3 +18,8 @@
                 .body(ErrorDto.builder().message(ex.getMessage()).build());
     }
+
+    @ExceptionHandler(HttpMessageNotWritableException.class)
+    public ResponseEntity<String> handleHttpMessageNotWritableException(HttpMessageNotWritableException ex) {
+        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the response.");
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/config/SecurityConfig.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/config/SecurityConfig.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/config/SecurityConfig.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -19,4 +19,5 @@
 import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
 import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
+import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.context.annotation.Bean;
@@ -26,4 +27,6 @@
 import org.springframework.security.web.SecurityFilterChain;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import java.util.List;
 
 @Configuration
@@ -55,37 +58,14 @@
     }
 
-//    @Bean
-//    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
-//        http
-//                .exceptionHandling(exception -> exception.authenticationEntryPoint(customerAuthenticationEntryPoint))
-//                .addFilterBefore(new JwtAuthFilter(userAuthProvider), BasicAuthenticationFilter.class)
-//                .csrf(AbstractHttpConfigurer::disable)
-//                .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
-//                .authorizeHttpRequests(requests -> requests
-//                        .requestMatchers(HttpMethod.POST, "/api/login", "/api/register").permitAll()
-//                        .requestMatchers("/", "/home").authenticated()  // Restrict `/` to authenticated users
-//                        .anyRequest().authenticated()
-//                )
-//                .logout(logout -> logout
-//                        .logoutUrl("/logout")
-//                        .clearAuthentication(true)
-//                        .invalidateHttpSession(true)
-//                        .deleteCookies("JSESSIONID")
-//                        .logoutSuccessUrl("/api/login")  // Redirect to login page after logout
-//                );
-//
-//        return http.build();
-//    }
-
     @Bean
     public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
         http
-                .exceptionHandling((exception) -> exception.authenticationEntryPoint(customerAuthenticationEntryPoint))
-                .addFilterBefore(new JwtAuthFilter(userAuthProvider), BasicAuthenticationFilter.class)
                 .csrf(AbstractHttpConfigurer::disable)
-                .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
-                .authorizeHttpRequests((requests) -> requests
-                        .requestMatchers(HttpMethod.POST, "/api/login", "/api/register").permitAll()
-                        .anyRequest().authenticated());
+                .authorizeHttpRequests(auth -> auth
+                        .requestMatchers("/api/auth/**").permitAll()
+                        .requestMatchers("/api/user/**", "/api/cuisineTypes", "/api/restaurants").authenticated()
+                )
+                .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
+
         return http.build();
     }
Index: src/main/java/com/example/rezevirajmasa/demo/dto/ReservationDTO.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/dto/ReservationDTO.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/dto/ReservationDTO.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,2 +1,140 @@
-package com.example.rezevirajmasa.demo.dto;public class ReservationDTO {
+package com.example.rezevirajmasa.demo.dto;
+
+import com.example.rezevirajmasa.demo.model.Reservation;
+import com.example.rezevirajmasa.demo.model.Restaurant;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+public class ReservationDTO {
+    private Long reservationID;
+    private String userEmail;
+    private BigDecimal rating;
+    private Long tableNumber;
+    private LocalDateTime reservationDateTime;
+    private LocalDateTime checkInTime;
+    private Restaurant restaurant;
+    private int partySize;
+    private String status;
+    private String specialRequests;
+    private String paymentStatus;
+
+    public ReservationDTO() {
+    }
+
+    public ReservationDTO(Long reservationID, String userEmail, BigDecimal rating, Long tableNumber, LocalDateTime reservationDateTime, LocalDateTime checkInTime, Restaurant restaurant, int partySize, String status, String specialRequests, String paymentStatus) {
+        this.reservationID = reservationID;
+        this.userEmail = userEmail;
+        this.rating = rating;
+        this.tableNumber = tableNumber;
+        this.reservationDateTime = reservationDateTime;
+        this.checkInTime = checkInTime;
+        this.restaurant = restaurant;
+        this.partySize = partySize;
+        this.status = status;
+        this.specialRequests = specialRequests;
+        this.paymentStatus = paymentStatus;
+    }
+
+    public ReservationDTO(Reservation reservation) {
+        this.reservationID = reservation.getReservationID();
+        this.userEmail = reservation.getUser().getEmail();
+        this.rating = reservation.getRestaurant().getRating();
+        this.tableNumber = reservation.getTable().getId();
+        this.reservationDateTime = reservation.getReservationDateTime();
+        this.checkInTime = reservation.getCheckInTime();
+        this.restaurant = reservation.getRestaurant();
+        this.partySize = reservation.getPartySize();
+        this.status = reservation.getStatus();
+        this.specialRequests = reservation.getSpecialRequests();
+        this.paymentStatus = reservation.getPaymentStatus();
+    }
+
+    public Long getReservationID() {
+        return reservationID;
+    }
+
+    public void setReservationID(Long reservationID) {
+        this.reservationID = reservationID;
+    }
+
+    public String getUserEmail() {
+        return userEmail;
+    }
+
+    public void setUserEmail(String userEmail) {
+        this.userEmail = userEmail;
+    }
+
+    public BigDecimal getRating() {
+        return rating;
+    }
+
+    public void setRating(BigDecimal rating) {
+        this.rating = rating;
+    }
+
+    public Long getTableNumber() {
+        return tableNumber;
+    }
+
+    public void setTableNumber(Long tableNumber) {
+        this.tableNumber = tableNumber;
+    }
+
+    public LocalDateTime getReservationDateTime() {
+        return reservationDateTime;
+    }
+
+    public void setReservationDateTime(LocalDateTime reservationDateTime) {
+        this.reservationDateTime = reservationDateTime;
+    }
+
+    public LocalDateTime getCheckInTime() {
+        return checkInTime;
+    }
+
+    public void setCheckInTime(LocalDateTime checkInTime) {
+        this.checkInTime = checkInTime;
+    }
+
+    public Restaurant getRestaurant() {
+        return restaurant;
+    }
+
+    public void setRestaurant(Restaurant restaurant) {
+        this.restaurant = restaurant;
+    }
+
+    public int getPartySize() {
+        return partySize;
+    }
+
+    public void setPartySize(int partySize) {
+        this.partySize = partySize;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getSpecialRequests() {
+        return specialRequests;
+    }
+
+    public void setSpecialRequests(String specialRequests) {
+        this.specialRequests = specialRequests;
+    }
+
+    public String getPaymentStatus() {
+        return paymentStatus;
+    }
+
+    public void setPaymentStatus(String paymentStatus) {
+        this.paymentStatus = paymentStatus;
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/dto/RestaurantDTO.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/dto/RestaurantDTO.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/dto/RestaurantDTO.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,2 +1,127 @@
-package com.example.rezevirajmasa.demo.dto;public class RestaurantDTO {
+package com.example.rezevirajmasa.demo.dto;
+
+import com.example.rezevirajmasa.demo.model.Restaurant;
+
+import java.util.List;
+
+public class RestaurantDTO {
+    private Long restaurantId;
+    private String name;
+    private String cuisineType;
+    private String address;
+    private String phone;
+    private String operatingHours;
+    private String website;
+    private String socialMediaLinks;
+    private Double rating;
+    private List<TableDTO> tablesList;
+
+    public RestaurantDTO() {
+    }
+
+    public RestaurantDTO(Long restaurantId, String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, Double rating, List<TableDTO> tablesList) {
+        this.restaurantId = restaurantId;
+        this.name = name;
+        this.cuisineType = cuisineType;
+        this.address = address;
+        this.phone = phone;
+        this.operatingHours = operatingHours;
+        this.website = website;
+        this.socialMediaLinks = socialMediaLinks;
+        this.rating = rating;
+        this.tablesList = tablesList;
+    }
+
+//    public RestaurantDTO(Restaurant restaurant) {
+//        this.restaurantId = restaurant.getRestaurantId();
+//        this.name = restaurant.getName();
+//        this.cuisineType = restaurant.getCuisineType();
+//        this.address = restaurant.getAddress();
+//        this.phone = restaurant.getPhone();
+//        this.operatingHours = restaurant.getOperatingHours();
+//        this.website = restaurant.getWebsite();
+//        this.socialMediaLinks = restaurant.getSocialMediaLinks();
+//        this.rating = restaurant.getRating().doubleValue();
+//        this.tablesList = restaurant.getTablesList();
+//    }
+
+    public Long getRestaurantId() {
+        return restaurantId;
+    }
+
+    public void setRestaurantId(Long restaurantId) {
+        this.restaurantId = restaurantId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCuisineType() {
+        return cuisineType;
+    }
+
+    public void setCuisineType(String cuisineType) {
+        this.cuisineType = cuisineType;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getOperatingHours() {
+        return operatingHours;
+    }
+
+    public void setOperatingHours(String operatingHours) {
+        this.operatingHours = operatingHours;
+    }
+
+    public String getWebsite() {
+        return website;
+    }
+
+    public void setWebsite(String website) {
+        this.website = website;
+    }
+
+    public String getSocialMediaLinks() {
+        return socialMediaLinks;
+    }
+
+    public void setSocialMediaLinks(String socialMediaLinks) {
+        this.socialMediaLinks = socialMediaLinks;
+    }
+
+    public Double getRating() {
+        return rating;
+    }
+
+    public void setRating(Double rating) {
+        this.rating = rating;
+    }
+
+    public List<TableDTO> getTablesList() {
+        return tablesList;
+    }
+
+    public void setTablesList(List<TableDTO> tablesList) {
+        this.tablesList = tablesList;
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/dto/TableDTO.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/dto/TableDTO.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/dto/TableDTO.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,2 +1,74 @@
-package com.example.rezevirajmasa.demo.dto;public class TableDTO {
+package com.example.rezevirajmasa.demo.dto;
+
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@NoArgsConstructor
+    public class TableDTO {
+        private Long id;
+        private Integer capacity;
+        private String location;
+        private String description;
+        private Integer reservationDurationHours;
+        private List<ReservationDTO> reservations;
+
+    public TableDTO(Long id, Integer capacity, String location, String description, Integer reservationDurationHours, List<ReservationDTO> reservations) {
+        this.id = id;
+        this.capacity = capacity;
+        this.location = location;
+        this.description = description;
+        this.reservationDurationHours = reservationDurationHours;
+        this.reservations = reservations;
+    }
+
+    // Getters and setters
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Integer getCapacity() {
+        return capacity;
+    }
+
+    public void setCapacity(Integer capacity) {
+        this.capacity = capacity;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Integer getReservationDurationHours() {
+        return reservationDurationHours;
+    }
+
+    public void setReservationDurationHours(Integer reservationDurationHours) {
+        this.reservationDurationHours = reservationDurationHours;
+    }
+
+    public List<ReservationDTO> getReservations() {
+        return reservations;
+    }
+
+    public void setReservations(List<ReservationDTO> reservations) {
+        this.reservations = reservations;
+    }
 }
+
Index: src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,6 +1,9 @@
 package com.example.rezevirajmasa.demo.model;
 
+import com.fasterxml.jackson.annotation.JsonBackReference;
+import com.fasterxml.jackson.annotation.JsonManagedReference;
 import jakarta.persistence.*;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -17,8 +20,10 @@
     @ManyToOne
     @JoinColumn(name = "UserID")
+    @JsonManagedReference
     private User user;
 
     @ManyToOne
     @JoinColumn(name = "TableNumber", nullable = false)
+    @JsonBackReference
     private TableEntity table;
 
@@ -36,5 +41,5 @@
     private String specialRequests;
 
-    @Column(name = "Status", length = 20, nullable = false, columnDefinition = "VARCHAR default 'Pending'")
+    @Column(name = "Status", length = 20, nullable = false)
     private String status;
 
@@ -46,5 +51,5 @@
 
 //    @Column(name = "TotalAmount", precision = 8, scale = 2)
-//    private BigDecimal totalAmount;//rezervacija so depozit ako e
+//    private BigDecimal totalAmount;
 
     @Column(name = "PaymentStatus", length = 20, nullable = false, columnDefinition = "VARCHAR default 'Unpaid'")
@@ -55,9 +60,6 @@
     }
 
-    // Constructors, getters, setters, and other methods...
-
     @PrePersist
     private void prePersist() {
-        // Set default values or perform any pre-persistence logic if needed
         if (status == null) {
             status = "Pending";
Index: src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -12,5 +12,4 @@
 @Table(name = "restaurants")
 public class Restaurant {
-
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -42,6 +41,6 @@
     private BigDecimal rating;
 
-    @JsonManagedReference
-    @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+    @JsonIgnore
+    @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
     private List<TableEntity> tablesList;
 
Index: src/main/java/com/example/rezevirajmasa/demo/model/TableEntity.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/TableEntity.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/model/TableEntity.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -2,5 +2,9 @@
 
 import com.fasterxml.jackson.annotation.JsonBackReference;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonManagedReference;
 import jakarta.persistence.*;
+import lombok.Getter;
+import lombok.Setter;
 import org.springframework.web.bind.annotation.ModelAttribute;
 
@@ -15,4 +19,6 @@
 
 @Entity
+@Getter
+@Setter
 @Table(name = "tables")
 public class TableEntity {
@@ -39,92 +45,52 @@
     private String description;
 
-    @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name = "table_time_slots", joinColumns = @JoinColumn(name = "table_id"))
-    @Column(name = "time_slot", columnDefinition = "timestamp without time zone")
-    @OrderBy("time_slot ASC")
-    private List<LocalDateTime> timeSlots = new ArrayList<>();
-
     @Column(name = "reservation_duration_hours", nullable = true)
     private int reservationDurationHours = 2;
+
+    @OneToMany(mappedBy = "table", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+    @JsonIgnore
+    private List<Reservation> reservations = new ArrayList<>(); // Store reservations, not time slots
+
     public void cleanUnusedTimeSlots(LocalDate threeDaysAgo) {
-        // Iterate over the time slots and remove those that are in the past
-        timeSlots.removeIf(timeSlot -> timeSlot.isBefore(threeDaysAgo.atStartOfDay()));
+        reservations.removeIf(reservation -> reservation.getReservationDateTime().toLocalDate().isBefore(threeDaysAgo));
     }
 
-    public void addTimeSlot(LocalDateTime timeSlot) {
-        this.timeSlots.add(timeSlot);
-    }
-
-
-    @Transient
-    public boolean isAvailable(LocalDateTime desiredTimeSlot) {
-        if (timeSlots == null || timeSlots.isEmpty()) {
-            return true;
+    public boolean isAvailable(LocalDateTime desiredTimeSlot, int partySize) {
+        if (this.capacity < partySize) {
+            return false;
         }
 
-        for (LocalDateTime reservedTimeSlot : timeSlots) {
-            LocalDateTime endTime = reservedTimeSlot.plusHours(reservationDurationHours);
+        for (Reservation reservation : reservations) {
+            LocalDateTime startTime = reservation.getReservationDateTime();
+            LocalDateTime endTime = startTime.plusHours(reservation.getTable().getReservationDurationHours());
 
-            // Check if the desired time slot overlaps with any existing reservation
-            if ((desiredTimeSlot.equals(reservedTimeSlot) || desiredTimeSlot.isAfter(reservedTimeSlot))
+            if ((desiredTimeSlot.isEqual(startTime) || desiredTimeSlot.isAfter(startTime))
                     && desiredTimeSlot.isBefore(endTime)) {
-                return false; // Table is reserved for the desired time slot
+                return false;
             }
         }
 
-        return true; // No conflicting reservations, table is available
+        return true;
     }
 
-    public boolean hasTimeSlot(LocalDateTime dateTime) {
-        // Check if the given dateTime exists in the list of time slots
-        return timeSlots.contains(dateTime);
+    public void addReservation(Reservation reservation) {
+        LocalDateTime startTime = reservation.getReservationDateTime();
+        LocalDateTime endTime = startTime.plusHours(reservation.getTable().getReservationDurationHours());
+        for (LocalDateTime timeSlot = startTime; timeSlot.isBefore(endTime); timeSlot = timeSlot.plusMinutes(15)) {
+
+        }
+        this.reservations.add(reservation);
     }
 
-    public List<LocalDateTime> initializeTimeSlots(LocalTime startTime, LocalTime endTime, List<LocalDate> dates, List<LocalDateTime> listOfUsedCheckIns) {
-        // Check if time slots are already initialized and cover all provided dates
-        List<LocalDate> generatedDates = timeSlots.stream()
-                .map(LocalDateTime::toLocalDate)
-                .distinct()
-                .toList();
+    public void removeReservation(Reservation reservation) {
+        LocalDateTime startTime = reservation.getReservationDateTime();
+        LocalDateTime endTime = startTime.plusHours(reservation.getTable().getReservationDurationHours());
+        for (LocalDateTime timeSlot = startTime; timeSlot.isBefore(endTime); timeSlot = timeSlot.plusMinutes(15)) {
 
-        if (generatedDates.containsAll(dates) && dates.containsAll(generatedDates)) {
-            System.out.println("Time slots already cover all provided dates.");
-            return timeSlots;
         }
-
-        // Generate time slots for the remaining dates
-        for (LocalDate date : dates) {
-            if (!generatedDates.contains(date)) {
-                LocalTime currentTime = startTime;
-                while (currentTime.isBefore(LocalTime.of(23, 0))) {
-                    LocalDateTime currentDateTime = LocalDateTime.of(date, currentTime);
-                    boolean isUsed = false;
-                    if (listOfUsedCheckIns != null) {
-                        for (LocalDateTime checkIns : listOfUsedCheckIns) {
-                            if (checkIns.isEqual(currentDateTime)) {
-                                isUsed = true;
-                                break;
-                            }
-                        }
-                    }
-                    if (!isUsed) {
-                        timeSlots.add(currentDateTime);
-                        System.out.println("Added time slot: " + currentDateTime); // Debug output
-                    } else {
-                        // Remove conflicting time slots
-                        timeSlots.removeIf(x -> x.isAfter(currentDateTime.minusHours(2)) && x.isBefore(currentDateTime.plusHours(2)));
-                    }
-                    // Increment currentTime
-                    currentTime = currentTime.plusMinutes(15);
-                }
-            }
-        }
-
-        return timeSlots;
+        this.reservations.remove(reservation);
     }
 
-
-
-    public TableEntity(Restaurant restaurant, int capacity, String location, boolean isSmokingArea, String description, List<LocalDateTime> timeSlots, int reservationDurationHours) {
+    public TableEntity(Restaurant restaurant, int capacity, String location, boolean isSmokingArea, String description, int reservationDurationHours) {
         this.restaurant = restaurant;
         this.capacity = capacity;
@@ -132,5 +98,4 @@
         this.isSmokingArea = isSmokingArea;
         this.description = description;
-        this.timeSlots = timeSlots;
         this.reservationDurationHours = reservationDurationHours;
     }
@@ -138,67 +103,3 @@
     public TableEntity() {
     }
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Restaurant getRestaurant() {
-        return restaurant;
-    }
-
-    public void setRestaurant(Restaurant restaurant) {
-        this.restaurant = restaurant;
-    }
-
-    public int getCapacity() {
-        return capacity;
-    }
-
-    public void setCapacity(int capacity) {
-        this.capacity = capacity;
-    }
-
-    public String getLocation() {
-        return location;
-    }
-
-    public void setLocation(String location) {
-        this.location = location;
-    }
-
-    public void setSmokingArea(Boolean isSmokingArea) {
-        this.isSmokingArea = isSmokingArea;
-    }
-
-    public void setSmokingArea(boolean smokingArea) {
-        isSmokingArea = smokingArea;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public List<LocalDateTime> getTimeSlots() {
-        return timeSlots;
-    }
-
-    public void setTimeSlots(List<LocalDateTime> timeSlots) {
-        this.timeSlots = timeSlots;
-    }
-
-    public int getReservationDurationHours() {
-        return reservationDurationHours;
-    }
-
-    public void setReservationDurationHours(int reservationDurationHours) {
-        this.reservationDurationHours = reservationDurationHours;
-    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/model/User.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/User.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/model/User.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,4 +1,5 @@
 package com.example.rezevirajmasa.demo.model;
 
+import com.fasterxml.jackson.annotation.JsonBackReference;
 import jakarta.persistence.*;
 import lombok.AllArgsConstructor;
@@ -48,5 +49,4 @@
 
     @Column(name = "RegistrationDate", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
-    @Temporal(TemporalType.TIMESTAMP)
     private Date registrationDate;
 }
Index: src/main/java/com/example/rezevirajmasa/demo/repository/ReservationRepository.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/repository/ReservationRepository.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/repository/ReservationRepository.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -15,3 +15,10 @@
     List<Reservation> findByCheckInTimeAfterAndCheckInTimeBefore(LocalDateTime startTime, LocalDateTime endTime);
     List<Reservation> findALlByUserAndCheckInTimeBefore(User user, LocalDateTime now);
+    List<Reservation> findAllByUser(User user);
+
+    List<Reservation> findAllByUserAndCheckInTimeAfter(User user, LocalDateTime now);
+
+    List<Reservation> findAllByUserAndCheckInTimeBefore(User user, LocalDateTime now);
+    List<Reservation> findAllByTableAndCheckInTime(TableEntity table, LocalDateTime now);
+    List<Reservation> findAllByRestaurantAndCheckInTimeAfter(Restaurant restaurant, LocalDateTime now);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/repository/TableRepository.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/repository/TableRepository.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/repository/TableRepository.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -12,6 +12,9 @@
 public interface TableRepository extends JpaRepository<TableEntity, Long> {
     List<TableEntity> findByRestaurant(Restaurant restaurant);
-//    @Query("SELECT t FROM TableEntity t JOIN FETCH t.restaurant WHERE t.id = :id")
-//    TableEntity findTableEntityByIdWithRestaurant(@Param("id") Long id);
-    List<TableEntity> findAllByTimeSlotsContainingAndCapacityGreaterThanEqual(LocalDateTime timeSlot, Integer partySize);
+    List<TableEntity> findAllByCapacityGreaterThanEqual(int capacity);
+    @Query("SELECT t FROM TableEntity t WHERE t.capacity >= :capacity AND NOT EXISTS (" +
+            "SELECT r FROM t.reservations r WHERE r.checkInTime <= :checkOutTime AND r.checkOutTime >= :checkInTime)")
+    List<TableEntity> findAvailableTables(@Param("checkInTime") LocalDateTime checkInTime,
+                                          @Param("checkOutTime") LocalDateTime checkOutTime,
+                                          @Param("capacity") int capacity);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/ReservationHistoryService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/ReservationHistoryService.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/ReservationHistoryService.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -11,4 +11,5 @@
 public interface ReservationHistoryService {
     public void moveReservationToHistory(Reservation reservation, String status, String cancellationReason);
+//    public void moveReservationToCancelled(Reservation reservation, String status, String cancellationReason);
     public void moveReservationsToPast(List<Restaurant.ReservationHistory> reservationsToMove);
     List<Restaurant.ReservationHistory> findByUser(User user);
Index: src/main/java/com/example/rezevirajmasa/demo/service/ReservationService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/ReservationService.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/ReservationService.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,5 +1,8 @@
 package com.example.rezevirajmasa.demo.service;
 
+import com.example.rezevirajmasa.demo.dto.ReservationDTO;
+import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
 import com.example.rezevirajmasa.demo.model.*;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.security.core.userdetails.UserDetails;
 
@@ -8,14 +11,19 @@
 
 public interface ReservationService {
-    public void makeReservation(User user, TableEntity table, Restaurant restaurant, LocalDateTime localDateTime, LocalDateTime checkInTime, int partySize, String specialRequests);
-    public Reservation makeReservationRest(Reservation reservation, User user);
+    public Reservation makeReservationRest(ReservationDTO reservation, User user);
     public List<Reservation> listAll();
+    public Reservation updateReservation(Long reservationId, ReservationDTO reservationDTO, User user);
+    public List<Reservation> reservationsForTable(TableEntity table);
     public Reservation findById(Long id);
     public Reservation getReservationById(Long reservationId);
     public boolean cancelReservation(Long reservationId);
     public List<Reservation> findReservationByUser(User user);
+    public List<Reservation> findAllByUser(User user);
     public List<Reservation> findReservationsByUserPast(User user);
     public List<Reservation> findReservationsByTableAndDateRange(TableEntity table, LocalDateTime startDateTime, LocalDateTime endDateTime);
-    List<Reservation> findReservationsToMove(LocalDateTime currentTime);
+    @Scheduled(cron = "0 0 0 * * ?")
+    void findReservationsToMove();
     void deleteReservation(Long reservationID);
+
+    List<Reservation> findAllByRestaurant(Restaurant restaurant);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/RestaurantService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/RestaurantService.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/RestaurantService.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,4 +1,5 @@
 package com.example.rezevirajmasa.demo.service;
 
+import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
 import com.example.rezevirajmasa.demo.model.Restaurant;
 import com.example.rezevirajmasa.demo.model.TableEntity;
@@ -10,16 +11,19 @@
 
 public interface RestaurantService {
-    List<Restaurant> listall();
-//    void save(String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, List<Long> tablesList);
+    List<RestaurantDTO> listall();
+    List<Restaurant> listAll();
+    //    void save(String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, List<Long> tablesList);
 //    void save(String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, int numberOfTables, int tableCapacity, String location, Boolean isSmokingArea, String description);
     void save(Restaurant restaurant, int numberOfTables, List<Integer> tableCapacities, List<String> tableLocations, List<String> tableSmokingAreas, List<String> tableDescriptions);
     Restaurant updateRestaurant(Long restaurantId, String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, List<Long> tablesList);
     Restaurant deleteRestaurant(Long restaurantId);
-    Restaurant findById(Long restaurantId);
+    RestaurantDTO findById(Long restaurantId);
+    Restaurant findByIdRestaurant(Long restaurantId);
     List<Restaurant> listRestaurantBy(String search);
     List<Restaurant> getRestaurantsWithAvailableTimeSlotsForToday();
     public List<Restaurant> findRestaurantsByDateTimeAndPartySize(LocalDateTime dateTime, int partySize, String search);
-    public List<Restaurant> findRestaurantsBySearchParams(LocalDateTime dateTime, int partySize, String search);
+//    public List<Restaurant> findRestaurantsBySearchParams(LocalDateTime dateTime, int partySize, String search);
     public List<String> findALlCuisineTypes();
-    List<Restaurant> findRestaurantsByCuisineType(String param);
+    List<RestaurantDTO> findRestaurantsByCuisineType(String param);
+    public List<RestaurantDTO> findRestaurantsBySearchParams(LocalDateTime dateTime, int partySize, String search);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/TableService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/TableService.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/TableService.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,4 +1,5 @@
 package com.example.rezevirajmasa.demo.service;
 
+import com.example.rezevirajmasa.demo.dto.TableDTO;
 import com.example.rezevirajmasa.demo.model.Restaurant;
 import com.example.rezevirajmasa.demo.model.TableEntity;
@@ -12,6 +13,7 @@
 public interface TableService {
     List<TableEntity> listall();
-    TableEntity findById(Long id);
-//    void save(int numberOfTables, List<Integer> tableCapacities, List<String> tableLocations, List<String> tableSmokingAreas, List<String> tableDescriptions, Restaurant restaurant);
+    TableDTO findById(Long id);
+    TableEntity findByIdTable(Long id);
+    void save(int numberOfTables, List<Integer> tableCapacities, List<String> tableLocations, List<String> tableSmokingAreas, List<String> tableDescriptions, Restaurant restaurant);
     void deleteTimeSlotsForReservation(Long tableId, LocalDateTime reservationTime);
     void canceledTimeSlots(Long tableId, LocalDateTime reservationTime);
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,4 +1,6 @@
 package com.example.rezevirajmasa.demo.service.impl;
 
+import com.example.rezevirajmasa.demo.dto.ReservationDTO;
+import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
 import com.example.rezevirajmasa.demo.dto.UserDto;
 import com.example.rezevirajmasa.demo.mappers.UserMapper;
@@ -12,4 +14,5 @@
 import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
 import com.example.rezevirajmasa.demo.service.ReservationService;
+import com.example.rezevirajmasa.demo.service.RestaurantService;
 import com.example.rezevirajmasa.demo.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,4 +34,5 @@
 @Service
 public class ReservationImpl implements ReservationService {
+
     @Autowired
     private TableRepository tableRepository;
@@ -51,45 +55,93 @@
 
     @Override
-    public void makeReservation(User user, TableEntity table, Restaurant restaurant, LocalDateTime localDateTime, LocalDateTime checkInTime, int partySize, String specialRequests) {
-        if (!table.isAvailable(checkInTime)) {
-            // Handle unavailability (throw an exception, return a specific response, etc.)
-            throw new RuntimeException("Table not available for the specified time slot");
-        }
-
-        Reservation reservation =
-                new Reservation(user, table, restaurant, LocalDateTime.now(), partySize, specialRequests, "Reserved", checkInTime, checkInTime.plusHours(2), null);
-
-//        // Update table status or perform additional logic if needed
-//        tableRepository.save(table);
-
-        // Save the reservation
-        reservationRepository.save(reservation);
-    }
-
-    @Override
-    public Reservation makeReservationRest(Reservation reservation, User user) {
-        Optional<TableEntity> optionalTable = tableRepository.findById(reservation.getTable().getId());
+    public Reservation makeReservationRest(ReservationDTO reservationDTO, User user) {
+        Reservation reservation = new Reservation();
+
+        Optional<TableEntity> optionalTable = tableRepository.findById(reservationDTO.getTableNumber());
+
         if (optionalTable.isPresent()) {
             TableEntity table = optionalTable.get();
 
+            LocalDateTime reservationTime = reservationDTO.getReservationDateTime();
+            LocalDateTime startTime = reservationTime.minusHours(2);
+            LocalDateTime endTime = reservationTime.plusHours(2);
+
+            boolean hasConflict = table.getReservations().stream()
+                    .anyMatch(existingReservation -> {
+                        LocalDateTime existingStartTime = existingReservation.getCheckInTime();
+                        LocalDateTime existingEndTime = existingReservation.getCheckOutTime();
+
+                        boolean scenario1 = existingStartTime.isBefore(startTime) && existingEndTime.isAfter(startTime);
+
+                        boolean scenario2 = existingStartTime.isBefore(endTime) && existingEndTime.isAfter(startTime);
+
+                        boolean scenario3 = existingStartTime.isAfter(startTime) && existingEndTime.isBefore(endTime);
+
+                        boolean scenario4 = existingStartTime.isBefore(startTime) && existingEndTime.isAfter(endTime);
+
+                        return scenario1 || scenario2 || scenario3 || scenario4;
+                    });
+            if (hasConflict) {
+                throw new InvalidReservationException("Unsuccessful reservation -> time slot not available");
+            }
+
+            reservation.setTable(table);
+            reservation.setReservationDateTime(LocalDateTime.now());
+            reservation.setSpecialRequests(reservationDTO.getSpecialRequests());
+            reservation.setPartySize(reservationDTO.getPartySize());
+            reservation.setStatus(reservationDTO.getStatus() != null ? reservationDTO.getStatus() : "Pending");
+            reservation.setPaymentStatus(reservationDTO.getPaymentStatus() != null ? reservationDTO.getPaymentStatus() : "Unpaid");
             reservation.setUser(user);
-
-            LocalDateTime startTime = reservation.getCheckInTime().minusHours(2);
-            LocalDateTime endTime = reservation.getCheckInTime().plusHours(2);
-
-            table.getTimeSlots().removeIf(
-                    x -> x.isAfter(startTime) && x.isBefore(endTime)
-            );
+            reservation.setRestaurant(reservationDTO.getRestaurant());
+            reservation.setCheckInTime(reservationTime);
             reservation.setReservationDateTime(LocalDateTime.now());
+            reservation.setCheckOutTime(reservationTime.plusHours(2));
+            reservation.setRestaurant(reservationDTO.getRestaurant());
+
             return reservationRepository.save(reservation);
         } else {
-            throw new InvalidReservationException("Unsuccessful reservation -> time slot not available");
-        }
-    }
-
+            throw new InvalidReservationException("Invalid table number -> table not found");
+        }
+    }
+
+    @Override
+    public Reservation updateReservation(Long reservationId, ReservationDTO reservationDTO, User user) {
+        Reservation existingReservation = findById(reservationId);
+
+        if (!existingReservation.getCheckInTime().equals(reservationDTO.getReservationDateTime())) {
+            TableEntity table = existingReservation.getTable();
+            table.removeReservation(existingReservation);
+
+            LocalDateTime newStartTime = reservationDTO.getReservationDateTime().minusHours(2);
+            LocalDateTime newEndTime = reservationDTO.getReservationDateTime().plusHours(2);
+            boolean hasConflict = table.getReservations().stream()
+                    .anyMatch(r -> r.getCheckInTime().isAfter(newStartTime) && r.getCheckInTime().isBefore(newEndTime));
+
+            if (hasConflict) {
+                throw new InvalidReservationException("New time slot is not available.");
+            }
+
+            table.addReservation(existingReservation);
+        }
+
+        existingReservation.setCheckInTime(reservationDTO.getReservationDateTime());
+        existingReservation.setCheckOutTime(reservationDTO.getReservationDateTime().plusHours(2));
+        existingReservation.setReservationDateTime(LocalDateTime.now());
+        existingReservation.setPartySize(reservationDTO.getPartySize());
+        existingReservation.setSpecialRequests(reservationDTO.getSpecialRequests());
+        existingReservation.setStatus(reservationDTO.getStatus() != null ? reservationDTO.getStatus() : existingReservation.getStatus());
+        existingReservation.setPaymentStatus(reservationDTO.getPaymentStatus() != null ? reservationDTO.getPaymentStatus() : existingReservation.getPaymentStatus());
+
+        return reservationRepository.save(existingReservation);
+    }
 
     @Override
     public List<Reservation> listAll() {
         return reservationRepository.findAll();
+    }
+
+    @Override
+    public List<Reservation> reservationsForTable(TableEntity table) {
+        return reservationRepository.findAllByTableAndCheckInTime(table, LocalDateTime.now());
     }
 
@@ -106,24 +158,9 @@
             TableEntity table = reservation.getTable();
 
-            LocalDateTime from = reservation.getCheckInTime().minusHours(2);
-            LocalDateTime till = reservation.getCheckInTime().plusHours(2);
-
-            String[] hours = table.getRestaurant().getOperatingHours().split("-");
-            LocalTime openingHourTime = LocalTime.parse(hours[0], DateTimeFormatter.ofPattern("HH:mm"));
-            LocalDateTime openingDateTime = openingHourTime.atDate(from.toLocalDate());
-            LocalTime closingHourTime = LocalTime.of(22,45);
-            LocalDateTime closingDateTime = closingHourTime.atDate(till.toLocalDate());
-            if(from.isBefore(openingDateTime)) {
-                from = openingDateTime;
-            }
-            if(till.isAfter(closingDateTime)) {
-                till = closingDateTime;
-            }
-            while (from.isBefore(reservation.getCheckInTime().plusHours(2))) {
-                table.addTimeSlot(from);
-                from = from.plusMinutes(15);
-            }
+            table.removeReservation(reservation);
+
             reservationHistoryService.moveReservationToHistory(reservation, "Canceled", "Canceled by user");
             reservationRepository.delete(reservation);
+
             return true;
         } else {
@@ -132,9 +169,13 @@
     }
 
-
     @Override
     public List<Reservation> findReservationByUser(User user) {
         LocalDateTime now = LocalDateTime.now();
-        return reservationRepository.findALlByUserAndCheckInTimeAfter(user, now);
+        return reservationRepository.findAllByUserAndCheckInTimeAfter(user, now);
+    }
+
+    @Override
+    public List<Reservation> findAllByUser(User user) {
+        return reservationRepository.findAllByUser(user);
     }
 
@@ -142,5 +183,5 @@
     public List<Reservation> findReservationsByUserPast(User user) {
         LocalDateTime now = LocalDateTime.now();
-        return reservationRepository.findALlByUserAndCheckInTimeBefore(user, now);
+        return reservationRepository.findAllByUserAndCheckInTimeBefore(user, now);
     }
 
@@ -151,6 +192,10 @@
 
     @Override
-    public List<Reservation> findReservationsToMove(LocalDateTime currentTime) {
-        return reservationRepository.findAllByCheckInTimeBefore(currentTime);
+    public void findReservationsToMove() {
+        List<Reservation> pastReservations = reservationRepository.findAllByCheckInTimeBefore(LocalDateTime.now());
+        for(Reservation reservation : pastReservations) {
+            reservationHistoryService.moveReservationToHistory(reservation, "successful", "/");
+            reservationRepository.delete(reservation);
+        }
     }
 
@@ -160,3 +205,8 @@
         reservationRepository.delete(reservation);
     }
+
+    @Override
+    public List<Reservation> findAllByRestaurant(Restaurant restaurant) {
+        return reservationRepository.findAllByRestaurantAndCheckInTimeAfter(restaurant, LocalDateTime.now());
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,15 +1,22 @@
 package com.example.rezevirajmasa.demo.service.impl;
 
+import com.example.rezevirajmasa.demo.dto.ReservationDTO;
+import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
+import com.example.rezevirajmasa.demo.dto.TableDTO;
+import com.example.rezevirajmasa.demo.model.Reservation;
 import com.example.rezevirajmasa.demo.model.Restaurant;
 import com.example.rezevirajmasa.demo.model.TableEntity;
+import com.example.rezevirajmasa.demo.model.User;
 import com.example.rezevirajmasa.demo.model.exceptions.InvalidRestaurantIdException;
 import com.example.rezevirajmasa.demo.repository.RestaurantRepository;
 import com.example.rezevirajmasa.demo.repository.TableRepository;
+import com.example.rezevirajmasa.demo.service.ReservationService;
 import com.example.rezevirajmasa.demo.service.RestaurantService;
 import com.example.rezevirajmasa.demo.service.TableService;
 import com.sun.tools.jconsole.JConsoleContext;
 import jakarta.transaction.Transactional;
+import org.openqa.selenium.InvalidArgumentException;
 import org.springframework.stereotype.Service;
-
+import org.modelmapper.ModelMapper;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -31,13 +38,42 @@
     private final TableRepository tableRepository;
     private final TableService tableService;
-
-    public RestaurantServiceImpl(RestaurantRepository restaurantRepository, TableRepository tableRepository, TableService tableService) {
+    private final ReservationService reservationService;
+    private ModelMapper modelMapper = new ModelMapper();
+
+    public RestaurantServiceImpl(RestaurantRepository restaurantRepository, TableRepository tableRepository, TableService tableService, ReservationService reservationService) {
         this.restaurantRepository = restaurantRepository;
         this.tableRepository = tableRepository;
         this.tableService = tableService;
-    }
-
-    @Override
-    public List<Restaurant> listall() {
+        this.reservationService = reservationService;
+    }
+
+    @Override
+    public List<RestaurantDTO> listall() {
+        List<Restaurant> restaurants = restaurantRepository.findAll();
+
+        List<RestaurantDTO> restaurantDTOS = new ArrayList<>();
+
+        for (Restaurant restaurant : restaurants) {
+            RestaurantDTO restaurantDTO = modelMapper.map(restaurant, RestaurantDTO.class);
+            List<TableDTO> tableDTOS = new ArrayList<>();
+            for (TableEntity table : restaurant.getTablesList()) {
+                TableDTO tableDTO = modelMapper.map(table, TableDTO.class);
+                List<ReservationDTO> reservationDTOS = new ArrayList<>();
+                for (Reservation reservation : table.getReservations()) {
+                    ReservationDTO reservationDTO = modelMapper.map(reservation, ReservationDTO.class);
+
+                    reservationDTOS.add(reservationDTO);
+                }
+                tableDTO.setReservations(reservationDTOS);
+                tableDTOS.add(tableDTO);
+            }
+            restaurantDTO.setTablesList(tableDTOS);
+            restaurantDTOS.add(restaurantDTO);
+        }
+        return restaurantDTOS;
+    }
+
+    @Override
+    public List<Restaurant> listAll() {
         return restaurantRepository.findAll();
     }
@@ -51,4 +87,8 @@
     @Override
     public void save(Restaurant restaurant, int numberOfTables, List<Integer> tableCapacities, List<String> tableLocations, List<String> tableSmokingAreas, List<String> tableDescriptions) {
+        if (numberOfTables != tableCapacities.size() || numberOfTables != tableLocations.size() || numberOfTables != tableSmokingAreas.size() || numberOfTables != tableDescriptions.size()) {
+            throw new IllegalArgumentException("Mismatched table data. Number of tables does not match the size of the input lists.");
+        }
+
         restaurantRepository.save(restaurant);
         String[] hours = restaurant.getOperatingHours().split("-");
@@ -60,19 +100,12 @@
             LocalTime startTime = LocalTime.parse(hours[0], DateTimeFormatter.ofPattern("HH:mm"));
             LocalTime endTime = LocalTime.parse(hours[1], DateTimeFormatter.ofPattern("HH:mm"));
-            System.out.println("IsBefore: " + startTime.isBefore(endTime) + " and equals: " + startTime.equals(endTime));
 
             for (int i = 0; i < numberOfTables; i++) {
                 TableEntity table = new TableEntity();
-
-//                table.initializeTimeSlots(startTime, endTime);
-
                 table.setCapacity(tableCapacities.get(i));
                 table.setLocation(tableLocations.get(i));
-
-                String smokingAreaString = tableSmokingAreas.get(i);
-                table.setSmokingArea(smokingAreaString.equalsIgnoreCase("on"));
+                table.setSmokingArea(tableSmokingAreas.get(i).equalsIgnoreCase("on"));
                 table.setDescription(tableDescriptions.get(i));
                 table.setRestaurant(restaurant);
-
                 tableRepository.save(table);
             }
@@ -84,7 +117,34 @@
     }
     @Override
-    public Restaurant findById(Long restaurantId) {
-        return restaurantRepository.findById(restaurantId).orElseThrow(InvalidRestaurantIdException::new);
-    }
+    public RestaurantDTO findById(Long restaurantId) {
+        Restaurant restaurant = restaurantRepository.findById(restaurantId)
+                .orElseThrow(InvalidRestaurantIdException::new);
+
+        RestaurantDTO restaurantDTO = modelMapper.map(restaurant, RestaurantDTO.class);
+
+        List<TableDTO> tableDTOS = new ArrayList<>();
+        for (TableEntity table : restaurant.getTablesList()) {
+            TableDTO tableDTO = modelMapper.map(table, TableDTO.class);
+
+            List<ReservationDTO> reservationDTOS = new ArrayList<>();
+            for (Reservation reservation : table.getReservations()) {
+                ReservationDTO reservationDTO = modelMapper.map(reservation, ReservationDTO.class);
+                reservationDTOS.add(reservationDTO);
+            }
+
+            tableDTO.setReservations(reservationDTOS);
+            tableDTOS.add(tableDTO);
+        }
+
+        restaurantDTO.setTablesList(tableDTOS);
+
+        return restaurantDTO;
+    }
+
+    @Override
+    public Restaurant findByIdRestaurant(Long restaurantId) {
+        return restaurantRepository.findById(restaurantId).orElseThrow(()-> new InvalidArgumentException("No restaurant with provided id"));
+    }
+
 
     @Override
@@ -115,5 +175,4 @@
     @Override
     public List<Restaurant> listRestaurantBy(String search) {
-        // Get all restaurants from the repository
         List<Restaurant> allRestaurants = restaurantRepository.findAll();
 
@@ -134,5 +193,4 @@
 
         for (Restaurant restaurant : restaurants) {
-            // Check if the restaurant has available time slots for today
             boolean hasAvailableTimeSlots = tableService.hasAvailableTimeSlotsForRestaurantAndDate(restaurant, today);
             if (hasAvailableTimeSlots) {
@@ -146,20 +204,15 @@
     @Override
     public List<Restaurant> findRestaurantsByDateTimeAndPartySize(LocalDateTime dateTime, int partySize, String search) {
+        LocalDateTime checkOutTime = dateTime.plusHours(2);
         List<Restaurant> allRestaurants = restaurantRepository.findAll();
+
         return allRestaurants.stream()
-                .filter(restaurant -> hasAvailableTable(restaurant, dateTime, partySize))
+                .filter(restaurant -> restaurant.getTablesList().stream()
+                        .anyMatch(table -> tableRepository.findAvailableTables(dateTime, checkOutTime, partySize)
+                                .contains(table)))
                 .filter(restaurant -> isMatch(restaurant, search))
                 .collect(Collectors.toList());
     }
 
-    private boolean hasAvailableTable(Restaurant restaurant, LocalDateTime dateTime, int partySize) {
-        for (TableEntity table : restaurant.getTablesList()) {
-            if (table.isAvailable(dateTime) && table.getCapacity() >= partySize) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     private boolean isMatch(Restaurant restaurant, String name) {
         return name == null || name.isEmpty() || restaurant.getName().contains(name);
@@ -167,19 +220,30 @@
 
     @Override
-    public List<Restaurant> findRestaurantsBySearchParams(LocalDateTime dateTime, int partySize, String search) {
+    public List<RestaurantDTO> findRestaurantsBySearchParams(LocalDateTime dateTime, int partySize, String search) {
+        List<Restaurant> availableRestaurants = new ArrayList<>();
+
+        List<Restaurant> restaurantList;
         if (search == null || search.isEmpty()) {
-            List<TableEntity> tableEntities = tableRepository.findAllByTimeSlotsContainingAndCapacityGreaterThanEqual(dateTime, partySize);
-            return tableEntities.stream()
-                    .map(TableEntity::getRestaurant)
-                    .distinct()
-                    .collect(Collectors.toList());
+            restaurantList = restaurantRepository.findAll();
         } else {
             String searchTerm = "%" + search + "%";
-            List<Restaurant> restaurantList = restaurantRepository.findAllByNameLikeIgnoreCase(searchTerm);
+            restaurantList = restaurantRepository.findAllByNameLikeIgnoreCase(searchTerm);
+
             if (restaurantList.isEmpty()) {
                 restaurantList = restaurantRepository.findAllByCuisineTypeContaining(search);
             }
-            return restaurantList;
-        }
+        }
+
+        for (Restaurant restaurant : restaurantList) {
+            boolean hasAvailableTable = restaurant.getTablesList().stream()
+                    .anyMatch(table -> table.isAvailable(dateTime, partySize));
+
+            if (hasAvailableTable) {
+                availableRestaurants.add(restaurant);
+            }
+        }
+
+        List<RestaurantDTO> restaurantDTOS = availableRestaurants.stream().map(this::convertToDto).toList();
+        return restaurantDTOS;
     }
 
@@ -190,6 +254,19 @@
 
     @Override
-    public List<Restaurant> findRestaurantsByCuisineType(String param) {
-        return restaurantRepository.findAllByCuisineType(param);
+    public List<RestaurantDTO> findRestaurantsByCuisineType(String param) {
+        List<Restaurant> restaurants = restaurantRepository.findAllByCuisineType(param);
+        return restaurants.stream().map(this::convertToDto).toList();
+    }
+
+    public RestaurantDTO convertToDto(Restaurant restaurant) {
+        return modelMapper.map(restaurant, RestaurantDTO.class);
+    }
+
+    public TableDTO convertToDto(TableEntity table) {
+        return modelMapper.map(table, TableDTO.class);
+    }
+
+    public ReservationDTO convertToDto(Reservation reservation) {
+        return modelMapper.map(reservation, ReservationDTO.class);
     }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/TableServiceImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/TableServiceImpl.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/TableServiceImpl.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,11 +1,18 @@
 package com.example.rezevirajmasa.demo.service.impl;
 
+import com.example.rezevirajmasa.demo.dto.ReservationDTO;
+import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
+import com.example.rezevirajmasa.demo.dto.TableDTO;
+import com.example.rezevirajmasa.demo.model.Reservation;
 import com.example.rezevirajmasa.demo.model.Restaurant;
 import com.example.rezevirajmasa.demo.model.TableEntity;
-import com.example.rezevirajmasa.demo.model.exceptions.InvalidRestaurantIdException;
 import com.example.rezevirajmasa.demo.model.exceptions.InvalidTableNumberException;
+import com.example.rezevirajmasa.demo.repository.ReservationRepository;
 import com.example.rezevirajmasa.demo.repository.RestaurantRepository;
 import com.example.rezevirajmasa.demo.repository.TableRepository;
 import com.example.rezevirajmasa.demo.service.TableService;
+import jakarta.persistence.Table;
+import org.modelmapper.ModelMapper;
+import org.openqa.selenium.InvalidArgumentException;
 import org.springframework.cglib.core.Local;
 import org.springframework.stereotype.Service;
@@ -18,4 +25,5 @@
 import java.time.chrono.ChronoLocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -25,13 +33,11 @@
     private final TableRepository tableRepository;
     private final RestaurantRepository restaurantRepository;
+    private final ReservationRepository reservationRepository;
+    private ModelMapper modelMapper = new ModelMapper();
 
-    public TableServiceImpl(TableRepository tableRepository, RestaurantRepository restaurantRepository) {
+    public TableServiceImpl(TableRepository tableRepository, RestaurantRepository restaurantRepository, ReservationRepository reservationRepository) {
         this.tableRepository = tableRepository;
         this.restaurantRepository = restaurantRepository;
-    }
-
-    @Override
-    public TableEntity findById(Long id) {
-        return tableRepository.findById(id).orElseThrow(InvalidTableNumberException::new);
+        this.reservationRepository = reservationRepository;
     }
 
@@ -41,4 +47,29 @@
     }
 
+    @Override
+    public TableDTO findById(Long id) {
+        TableEntity table = tableRepository.findById(id)
+                .orElseThrow(InvalidTableNumberException::new);
+
+        TableDTO tableDTO = modelMapper.map(table, TableDTO.class);
+
+        List<ReservationDTO> reservationDTOS = new ArrayList<>();
+        for (Reservation reservation : table.getReservations()) {
+            ReservationDTO reservationDTO = modelMapper.map(reservation, ReservationDTO.class);
+            reservationDTOS.add(reservationDTO);
+        }
+
+        tableDTO.setReservations(reservationDTOS);
+
+        return tableDTO;
+    }
+
+    @Override
+    public TableEntity findByIdTable(Long id) {
+        return tableRepository.findById(id).orElseThrow(() -> new InvalidArgumentException("Invalid table id"));
+    }
+
+
+    @Override
     public void save(int numberOfTables, List<Integer> tableCapacities, List<String> tableLocations, List<String> tableSmokingAreas, List<String> tableDescriptions, Restaurant restaurant) {
         for (int i = 0; i < numberOfTables; i++) {
@@ -55,13 +86,8 @@
     @Override
     public void deleteTimeSlotsForReservation(Long tableId, LocalDateTime reservationTime) {
-        LocalDateTime startTime = reservationTime.minusHours(2);
-        LocalDateTime endTime = reservationTime.plusHours(2);
-
-        TableEntity table = findById(tableId);
-        List<LocalDateTime> timeSlots = table.getTimeSlots();
-
-        timeSlots.removeIf(timeSlot -> timeSlot.isAfter(startTime) && timeSlot.isBefore(endTime));
-
-        table.setTimeSlots(timeSlots);
+        TableDTO tableDTO = findById(tableId);
+        TableEntity table = convertFromDTO(tableDTO);
+        LocalDate threeDaysAgo = LocalDate.now().minusDays(3);
+        table.cleanUnusedTimeSlots(threeDaysAgo);
 
         tableRepository.saveAndFlush(table);
@@ -70,27 +96,31 @@
     @Override
     public void canceledTimeSlots(Long tableId, LocalDateTime reservationTime) {
-        TableEntity table = findById(tableId);
-        List<LocalDateTime> timeSlots = table.getTimeSlots();
+        TableDTO tableDTO = findById(tableId);
+        TableEntity table = convertFromDTO(tableDTO);
         LocalDateTime startTime = reservationTime.minusHours(1).minusMinutes(45);
         LocalDateTime endTime = reservationTime.plusHours(1).plusMinutes(45);
 
-        LocalDate localDate = reservationTime.toLocalDate();
-
         String[] hours = table.getRestaurant().getOperatingHours().split("-");
         LocalTime openingHourTime = LocalTime.parse(hours[0], DateTimeFormatter.ofPattern("HH:mm"));
+        LocalDateTime openingHour = openingHourTime.atDate(reservationTime.toLocalDate());
+        LocalDateTime closingHour = LocalTime.of(23, 45).atDate(reservationTime.toLocalDate());
 
-        LocalDateTime openingHour = openingHourTime.atDate(localDate);
-        LocalDateTime closingHour = LocalTime.of(23, 45).atDate(localDate);
-        if(startTime.isBefore(openingHour)) {
-            startTime = LocalDateTime.from(openingHour);
+        if (startTime.isBefore(openingHour)) {
+            startTime = openingHour;
         }
-        while(startTime.isBefore(endTime) || startTime.equals(endTime)) {
-            timeSlots.add(startTime);
-            startTime = startTime.plusMinutes(15);
-            if(startTime.isAfter(closingHour) || startTime.equals(closingHour)) {
+
+        while (startTime.isBefore(endTime) || startTime.equals(endTime)) {
+            if (startTime.isAfter(closingHour) || startTime.equals(closingHour)) {
                 break;
             }
+
+            Reservation reservation = new Reservation();
+            reservation.setReservationDateTime(startTime);
+            reservation.setTable(table);
+            reservationRepository.save(reservation);
+
+            startTime = startTime.plusMinutes(15);
         }
-        table.setTimeSlots(timeSlots);
+
         tableRepository.saveAndFlush(table);
     }
@@ -105,4 +135,5 @@
         return tableRepository.findById(number).orElseThrow(InvalidTableNumberException::new);
     }
+
     @Override
     public TableEntity deleteTable(Long number) {
@@ -116,9 +147,8 @@
         List<TableEntity> tables = tableRepository.findByRestaurant(restaurant);
 
-        // Iterate through each table to check for available time slots
         for (TableEntity table : tables) {
             boolean hasAvailableTimeSlots = hasAvailableTimeSlotsForTableAndDate(table, today);
             if (hasAvailableTimeSlots) {
-                return true; // If any table has available time slots, return true
+                return true;
             }
         }
@@ -128,13 +158,29 @@
 
     public boolean hasAvailableTimeSlotsForTableAndDate(TableEntity table, LocalDate date) {
-        List<LocalDateTime> timeSlots = table.getTimeSlots();
+        for (Reservation reservation : table.getReservations()) {
+            LocalDateTime startTime = reservation.getReservationDateTime();
+            LocalDateTime endTime = startTime.plusHours(reservation.getTable().getReservationDurationHours());
 
-        // Implement your logic to check if the table has available time slots for the given date
-        // This could involve querying the database for reservations for the given table and date,
-        // and checking if there are any open time slots.
-        // You may need to consider factors such as operating hours, existing reservations, etc.
-        // Return true if there are available time slots, false otherwise.
-        return false;
+            if (startTime.toLocalDate().equals(date) || endTime.toLocalDate().equals(date)) {
+                return false;
+            }
+        }
+        return true;
     }
 
+    public RestaurantDTO convertToDto(Restaurant restaurant) {
+        return modelMapper.map(restaurant, RestaurantDTO.class);
+    }
+
+    public TableDTO convertToDto(TableEntity table) {
+        return modelMapper.map(table, TableDTO.class);
+    }
+
+    public ReservationDTO convertToDto(Reservation reservation) {
+        return modelMapper.map(reservation, ReservationDTO.class);
+    }
+
+    public TableEntity convertFromDTO(TableDTO tableDTO) {
+        return modelMapper.map(tableDTO, TableEntity.class);
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java	(revision f5b256e5542dc70faf511ecc16ef87cc3d52cce5)
+++ src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java	(revision deea3c4a0005ebc66d196fb9a5747758d15a025c)
@@ -1,8 +1,8 @@
 package com.example.rezevirajmasa.demo.web.rest;
 
-import com.example.rezevirajmasa.demo.dto.CustomerDTO;
-import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.dto.*;
 import com.example.rezevirajmasa.demo.mappers.UserMapper;
 import com.example.rezevirajmasa.demo.model.*;
+import com.example.rezevirajmasa.demo.model.exceptions.InvalidReservationException;
 import com.example.rezevirajmasa.demo.service.*;
 import com.example.rezevirajmasa.demo.service.impl.TokenService;
@@ -25,8 +25,6 @@
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @CrossOrigin(origins = "http://localhost:3000/")
@@ -57,18 +55,18 @@
     }
 
-    //restaurants
-
-    @RequestMapping("/api/restaurants")
-    public ResponseEntity<List<Restaurant>> getAllRestaurants() {
-        return new ResponseEntity<List<Restaurant>>(restaurantService.listall(), HttpStatus.OK);
-    }
-
-    @RequestMapping("/api/restaurants/{restaurantId}")
-    public ResponseEntity<Restaurant> getRestaurantById(@PathVariable Long restaurantId) {
-        return new ResponseEntity<Restaurant>(restaurantService.findById(restaurantId), HttpStatus.OK);
+    //restaurants calls
+
+    @GetMapping("/api/restaurants")
+    public ResponseEntity<List<RestaurantDTO>> getAllRestaurants() {
+            return new ResponseEntity<List<RestaurantDTO>>(restaurantService.listall(), HttpStatus.OK);
+    }
+
+    @GetMapping("/api/restaurants/{restaurantId}")
+    public ResponseEntity<RestaurantDTO> getRestaurantById(@PathVariable Long restaurantId) {
+        return new ResponseEntity<RestaurantDTO>(restaurantService.findById(restaurantId), HttpStatus.OK);
     }
 
     @PostMapping("/api/search")
-    public ResponseEntity<List<Restaurant>> searchRestaurants(@RequestBody Map<String, Object> requestData) {
+    public ResponseEntity<List<RestaurantDTO>> searchRestaurants(@RequestBody Map<String, Object> requestData) {
         Optional<String> dateTimeOptional = Optional.ofNullable((String) requestData.get("dateTime"));
         int partySize = Integer.parseInt(requestData.get("partySize").toString());
@@ -84,12 +82,12 @@
         }
 
-        List<Restaurant> filteredRestaurants = restaurantService.findRestaurantsBySearchParams(parsedDateTime, partySize, search);
-
-        return new ResponseEntity<List<Restaurant>>(filteredRestaurants, HttpStatus.OK);
+        List<RestaurantDTO> filteredRestaurants = restaurantService.findRestaurantsBySearchParams(parsedDateTime, partySize, search);
+
+        return new ResponseEntity<>(filteredRestaurants, HttpStatus.OK);
     }
 
     @PostMapping("/api/search/shortcut/{param}")
-    public ResponseEntity<List<Restaurant>> searchByCuisineTypeShortcut(@PathVariable String param) {
-        List<Restaurant> filteredRestaurants;
+    public ResponseEntity<List<RestaurantDTO>> searchByCuisineTypeShortcut(@PathVariable String param) {
+        List<RestaurantDTO> filteredRestaurants;
         if(param != null && !param.isEmpty()) {
             filteredRestaurants = restaurantService.findRestaurantsByCuisineType(param);
@@ -97,5 +95,5 @@
             filteredRestaurants = restaurantService.listall();
         }
-        return new ResponseEntity<List<Restaurant>>(filteredRestaurants, HttpStatus.OK);
+        return new ResponseEntity<List<RestaurantDTO>>(filteredRestaurants, HttpStatus.OK);
     }
 
@@ -106,7 +104,16 @@
     }
 
+    // User calls
+
+    @GetMapping("/api/user/{email}")
+    public ResponseEntity<User> getUserByEmail(@PathVariable String email)
+    {
+        User user = userService.findByMail(email);
+        return ResponseEntity.ok(user);
+    }
+
 //    Customer CALLS
 
-    @RequestMapping("/api/customers")
+    @GetMapping("/api/customers")
     public ResponseEntity<List<CustomerDTO>> getAllCustomers() {
         List<Customer> customers = customerService.listAll();
@@ -119,5 +126,5 @@
     }
 
-    @RequestMapping("/api/customers/{id}")
+    @GetMapping("/api/customers/{id}")
     public ResponseEntity<Customer> getCustomerById(@PathVariable Long id) {
         return new ResponseEntity<Customer>(customerService.findById(id), HttpStatus.OK);
@@ -130,16 +137,4 @@
         );
     }
-    @GetMapping("/api/user")
-    public ResponseEntity<?> getCurrentUser() {
-        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
-
-        if (authentication == null || !authentication.isAuthenticated() || authentication.getPrincipal().equals("anonymousUser")) {
-            return new ResponseEntity<>("User is not authenticated", HttpStatus.UNAUTHORIZED);
-        }
-
-        Customer customer = (Customer) authentication.getPrincipal();
-        return new ResponseEntity<>(customer, HttpStatus.OK);
-    }
-
 
     @PostMapping("/api/customers")
@@ -166,12 +161,24 @@
 
     @GetMapping("/api/reservations/by/{email}")
-    public ResponseEntity<List<Reservation>> getReservations(@PathVariable String email) {
-        User user = userService.findByMail(email);
-        return new ResponseEntity<List<Reservation>>(reservationService.findReservationByUser(user), HttpStatus.OK);
-    }
-
-    @PostMapping("/api/reservations/{email}")
-    public ResponseEntity<Reservation> createReservation(@RequestBody Reservation reservation, @PathVariable String email) {
-        User user = userService.findByMail(email);
+    public ResponseEntity<List<ReservationDTO>> getReservations(@PathVariable String email) {
+        if (email == null || email.isEmpty()) {
+            return ResponseEntity.badRequest().build();
+        }
+        User user = userService.findByMail(email);
+        if (user == null) {
+            return ResponseEntity.notFound().build();
+        }
+
+        List<Reservation> reservations = reservationService.findReservationByUser(user);
+        List<ReservationDTO> reservationDTOs = reservations.stream()
+                .map(ReservationDTO::new)
+                .collect(Collectors.toList());
+
+        return ResponseEntity.ok(reservationDTOs);
+    }
+
+    @PostMapping("/api/reservations")
+    public ResponseEntity<?> createReservation(@RequestBody ReservationDTO reservation) {
+        User user = userService.findByMail(reservation.getUserEmail());
         Reservation savedReservation = reservationService.makeReservationRest(reservation, user);
 
@@ -179,48 +186,58 @@
     }
 
-
     @GetMapping("/api/reservations/{reservationId}")
-    public ResponseEntity<Reservation> getReservation(@PathVariable Long reservationId) {
+    public ResponseEntity<ReservationDTO> getReservation(@PathVariable Long reservationId) {
         Reservation reservation = reservationService.findById(reservationId);
         if (reservation != null) {
-            return ResponseEntity.ok(reservation);
-        } else {
-            return ResponseEntity.notFound().build();
-        }
-    }
+            return ResponseEntity.ok(new ReservationDTO(reservation));
+        } else {
+            return ResponseEntity.notFound().build();
+        }
+    }
+
+//    @GetMapping("/api/reservations/{restaurantId}")
+//    public ResponseEntity<List<Reservation>> getReservationsByRestaurant(@PathVariable Long restaurantId)
+//    {
+//        Restaurant restaurant = restaurantService.findByIdRestaurant(restaurantId);
+//        List<Reservation> reservations = reservationService.findAllByRestaurant(restaurant);
+//        return ResponseEntity.ok(reservations);
+//    }
+
+    @GetMapping("/api/table-reservations/{tableId}")
+    public ResponseEntity<List<LocalDateTime>> tableReservations(@PathVariable Long tableId) {
+        TableEntity table = tableService.findByIdTable(tableId);
+        if (table == null) {
+            return ResponseEntity.notFound().build();
+        }
+
+        List<Reservation> reservations = reservationService.reservationsForTable(table);
+        List<LocalDateTime> reservedTimes = reservations.stream()
+                .map(Reservation::getReservationDateTime)
+                .collect(Collectors.toList());
+
+        return ResponseEntity.ok(reservedTimes);
+    }
+
 
     @PostMapping("/api/reservations/{reservationId}/{email}")
     public ResponseEntity<Reservation> editReservation(@PathVariable Long reservationId,
-                                                       @RequestBody Reservation reservation,
+                                                       @RequestBody ReservationDTO reservationDTO,
                                                        @PathVariable String email) {
         User user = userService.findByMail(email);
 
-        if (!reservation.getReservationID().equals(reservationId)) {
+        if (!reservationDTO.getReservationID().equals(reservationId)) {
             return ResponseEntity.badRequest().build();
         }
 
-        // Fetch existing reservation
-        Reservation existingReservation = reservationService.findById(reservationId);
-        if (existingReservation == null) {
-            return ResponseEntity.notFound().build();
-        }
-
-        if (!reservation.getCheckInTime().equals(existingReservation.getCheckInTime())) {
-            tableService.canceledTimeSlots(existingReservation.getTable().getId(), existingReservation.getCheckInTime());
-
-            tableService.deleteTimeSlotsForReservation(reservation.getTable().getId(), reservation.getCheckInTime());
-        }
-
-        existingReservation.setReservationDateTime(LocalDateTime.now());
-        existingReservation.setCheckInTime(reservation.getCheckInTime());
-        existingReservation.setCheckOutTime(reservation.getCheckInTime().plusHours(2));
-        existingReservation.setPartySize(reservation.getPartySize());
-        existingReservation.setSpecialRequests(reservation.getSpecialRequests());
-
-        Reservation updatedReservation = reservationService.makeReservationRest(existingReservation, user);
-
-        System.out.println("Updated reservation time: " + updatedReservation.getCheckInTime());
-        return ResponseEntity.ok(updatedReservation);
-    }
+        try {
+            Reservation updatedReservation = reservationService.updateReservation(reservationId, reservationDTO, user);
+            return ResponseEntity.ok(updatedReservation);
+        } catch (InvalidReservationException e) {
+            return ResponseEntity.status(409).body(null);
+        } catch (Exception e) {
+            return ResponseEntity.status(500).build();
+        }
+    }
+
 
 
@@ -241,9 +258,9 @@
     }
 
-//    TableEntity Calls
-
+    // TableEntity Calls
     @GetMapping("/api/tables/{tableId}")
-    public ResponseEntity<TableEntity> findTableById(@PathVariable Long tableId) {
-        return new ResponseEntity<TableEntity>(tableService.findById(tableId), HttpStatus.OK);
+    public ResponseEntity<TableDTO> findTableById(@PathVariable Long tableId) {
+        TableDTO tableDTO = tableService.findById(tableId);
+        return new ResponseEntity<>(tableDTO, HttpStatus.OK);
     }
 
@@ -255,4 +272,3 @@
         return new ResponseEntity<>(reservations, HttpStatus.OK);
     }
-
 }
