Skip to content

Instantly share code, notes, and snippets.

@abhishek-sisodiya
Last active July 30, 2019 10:21
Show Gist options
  • Save abhishek-sisodiya/7a5fcf251d531cd0015687d27ecd7dbe to your computer and use it in GitHub Desktop.
Save abhishek-sisodiya/7a5fcf251d531cd0015687d27ecd7dbe to your computer and use it in GitHub Desktop.
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