Changeset f8007b3 for src/main/java


Ignore:
Timestamp:
09/03/21 11:34:33 (3 years ago)
Author:
NikolaCenevski <cenevskinikola@…>
Branches:
master
Children:
194776a
Parents:
f0d5cb7
Message:

Ovozmozeno e azuriranje na podatoci za primeni sredstva preku banka

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/charitable/controller/UserProfileController.java

    rf0d5cb7 rf8007b3  
    11package it.finki.charitable.controller;
    22
    3 import it.finki.charitable.entities.AppUser;
    4 import it.finki.charitable.entities.DonationInformation;
    5 import it.finki.charitable.entities.DonationPost;
    6 import it.finki.charitable.entities.MainUser;
     3import it.finki.charitable.entities.*;
    74import it.finki.charitable.security.PasswordEncoder;
    85import it.finki.charitable.services.DonationPostService;
     6import it.finki.charitable.services.FundsCollectedService;
    97import it.finki.charitable.services.UserService;
    108import org.springframework.security.core.context.SecurityContextHolder;
     
    2321    private final UserService userService;
    2422    private final DonationPostService donationPostService;
     23    private final FundsCollectedService fundsCollectedService;
    2524
    26     public UserProfileController(UserService userService, DonationPostService donationPostService) {
     25    public UserProfileController(UserService userService, DonationPostService donationPostService, FundsCollectedService fundsCollectedService) {
    2726        this.userService = userService;
    2827        this.donationPostService = donationPostService;
     28        this.fundsCollectedService = fundsCollectedService;
    2929    }
    3030
     
    105105    }
    106106
     107    @RequestMapping("/addFunds")
     108    public String addFunds(@RequestParam Long postid,
     109                           @RequestParam String type,
     110                           @RequestParam float amount) {
     111
     112        DonationPost post = donationPostService.getById(postid);
     113        FundsCollected funds = new FundsCollected(type, amount);
     114        fundsCollectedService.save(funds);
     115
     116        post.getFundsCollected().add(funds);
     117        donationPostService.save(post);
     118        return "redirect:/myPosts";
     119    }
     120
    107121    @ModelAttribute("user")
    108122    public AppUser addAttributes() {
Note: See TracChangeset for help on using the changeset viewer.