Last active
July 30, 2019 10:21
-
-
Save abhishek-sisodiya/7a5fcf251d531cd0015687d27ecd7dbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.org.project.theWeatherMan.service; | |
/** | |
* This service will be used to implement user vote for provider. | |
* | |
* @author abhishek.sisodiya | |
* @since 01/07/2019. | |
*/ | |
@Service | |
public class VotingService { | |
@Autowired | |
private VotingDAO votingRepository; | |
public String userVote(Map<String, Object> payload) throws Exception { | |
VotingDTO voting = new VotingDTO(); | |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | |
String date = dateFormat.format(Calendar.getInstance().getTime()); | |
voting.setDate(date); | |
ProviderDTO provider = new ProviderDTO(); | |
provider.setId(Integer.parseInt(payload.get("providerId").toString())); | |
voting.setProvider(provider); | |
DTOUser user = new DTOUser(); | |
user.setId(Integer.parseInt(payload.get("userId").toString())); | |
voting.setUser(user); | |
try { | |
votingRepository.save(voting); | |
} catch (Exception e) { | |
return "Bad request."; | |
} | |
return "Thanks for your feedback."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment