use of com.axelor.apps.crm.db.repo.LeadRepository in project axelor-open-suite by axelor.
the class EventController method assignToMeLead.
@SuppressWarnings("rawtypes")
public void assignToMeLead(ActionRequest request, ActionResponse response) {
LeadService leadService = Beans.get(LeadService.class);
LeadRepository leadRepo = Beans.get(LeadRepository.class);
if (request.getContext().get("id") != null) {
Lead lead = leadRepo.find((Long) request.getContext().get("id"));
lead.setUser(AuthUtils.getUser());
if (lead.getStatusSelect() == LeadRepository.LEAD_STATUS_NEW)
lead.setStatusSelect(LeadRepository.LEAD_STATUS_ASSIGNED);
leadService.saveLead(lead);
} else if (((List) request.getContext().get("_ids")) != null) {
for (Lead lead : leadRepo.all().filter("id in ?1", request.getContext().get("_ids")).fetch()) {
lead.setUser(AuthUtils.getUser());
if (lead.getStatusSelect() == LeadRepository.LEAD_STATUS_NEW)
lead.setStatusSelect(LeadRepository.LEAD_STATUS_ASSIGNED);
leadService.saveLead(lead);
}
}
response.setReload(true);
}
Aggregations