Ignore:
Timestamp:
01/06/23 02:51:45 (23 months ago)
Author:
andrejtodorovski <82031894+andrejtodorovski@…>
Branches:
main
Children:
d4b888e
Parents:
1bd8d1e
Message:

Added full functionality for creating order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/autopartz/controller/AdminController.java

    r1bd8d1e rf484b14  
    11package com.example.autopartz.controller;
    22
     3import com.example.autopartz.model.Deliveryman;
    34import com.example.autopartz.model.Role;
    45import com.example.autopartz.model.User;
    56import com.example.autopartz.model.Warehouseman;
     7import com.example.autopartz.repository.DeliverymanRepository;
    68import com.example.autopartz.repository.WarehousemanRepository;
    79import com.example.autopartz.service.UserService;
     
    1315import org.springframework.web.bind.annotation.RequestMapping;
    1416
    15 import javax.annotation.security.RolesAllowed;
    1617import javax.servlet.http.HttpServletResponse;
    1718import java.io.IOException;
     
    2526    private final UserService userService;
    2627    private final WarehousemanRepository warehousemanRepository;
     28    private final DeliverymanRepository deliverymanRepository;
    2729
    28     public AdminController(UserService userService, WarehousemanRepository warehousemanRepository) {
     30    public AdminController(UserService userService, WarehousemanRepository warehousemanRepository, DeliverymanRepository deliverymanRepository) {
    2931        this.userService = userService;
    3032        this.warehousemanRepository = warehousemanRepository;
     33        this.deliverymanRepository = deliverymanRepository;
    3134    }
    3235
     
    4447            wh.setEmployed_from(LocalDate.now());
    4548            warehousemanRepository.save(wh);
     49
     50        }
     51        else {
     52            Deliveryman dm = (Deliveryman) userService.findById(id);
     53            dm.setEmployed_from(LocalDate.now());
     54            deliverymanRepository.save(dm);
    4655            try {
    4756                response.sendRedirect("/viewUsers");
Note: See TracChangeset for help on using the changeset viewer.