package org.itevents.tasks;

import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by ramax on 7/30/15.
 */

public class SendMailSubscribersTask {

    private static int i;

    public void sendMails(){
        System.out.println("Send mail" + i++);

    }

}

@@ -37,62 +37,105 @@
 org.
-springframework.scheduling.annotation.EnableScheduling
+itevents.model.Event;%0Aimport org.itevents.model.User;%0Aimport org.itevents.service.SendGridService
 ;%0Aim
@@ -163,18 +163,21 @@
 ork.
-scheduling
+beans.factory
 .ann
@@ -188,15 +188,15 @@
 ion.
-Schedul
+Autowir
 ed;%0A
@@ -212,29 +212,16 @@
 ava.
-text.SimpleDateFormat
+util.Map
 ;%0Aim
@@ -239,12 +239,11 @@
 til.
-Date
+Set
 ;%0A%0A/
@@ -330,28 +330,113 @@
     
-private static int i
+@Autowired%0A    private SendGridService sendGridService;%0A%0A    private Map%3CUser,Set%3CEvent%3E%3E userEventSetMap
 ;%0A%0A 
@@ -467,16 +467,17 @@
 ()%7B%0A
+%0A
         
 Syst
@@ -476,53 +476,388 @@
     
-System.out.println(%22Send mail%22 + i++
+for (Map.Entry%3CUser,Set%3CEvent%3E%3E entry: userEventSetMap.entrySet())%7B%0A%0A            User user = entry.getKey();%0A            for (Event event: entry.getValue()) %7B%0A                String message = getMessage(event);%0A                sendGridService.sendMail(message,user);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private String getMessage(Event event) %7B%0A        return event.toString(
 );%0A
-%0A
     %7D%0A
-%0A
 %7D%0A

change SendMailSubscribersTask