Search in sources :

Example 1 with LeadRepository

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);
}
Also used : LeadRepository(com.axelor.apps.crm.db.repo.LeadRepository) LeadService(com.axelor.apps.crm.service.LeadService) Lead(com.axelor.apps.crm.db.Lead)

Aggregations

Lead (com.axelor.apps.crm.db.Lead)1 LeadRepository (com.axelor.apps.crm.db.repo.LeadRepository)1 LeadService (com.axelor.apps.crm.service.LeadService)1