private void NotifyAccordingToNotificationType(Guid notificationBatchGuid, string notificationTypeName) { var notificationMessages = _notificationMessageService.GetByNotificationBatchIdAndNotificationType(notificationBatchGuid, notificationTypeName); var notifyMessage = _notificationMessageService.GetByNotificationBatchIdAndNotificationType(notificationBatchGuid, notificationTypeName).FirstOrDefault(); List <string> emailList = new List <string>(); foreach (var notificationMessage in notificationMessages) { var ob = _userService.GetUserByUserGuid(notificationMessage.UserGuid).WorkEmail; emailList.Add(ob); } EmailMessageModel usersToNotifyWithTemplate = new EmailMessageModel() { NotificationMessageGuid = notifyMessage.NotificationMessageGuid, Message = notifyMessage.Message, Subjects = notifyMessage.Subject, Status = notifyMessage.Status, AdditionalMessage = notifyMessage.AdditionalMessage, WorkEmail = string.Join(",", emailList), Displayname = _userService.GetUserByUserGuid(notifyMessage.UserGuid).DisplayName }; /* * todo make method GetNotificationTypeByNotificationBatchId - * todo to compare either Email Notification or SMS Notification in future.. */ _emailSender.SendEmailAsync(usersToNotifyWithTemplate.WorkEmail, usersToNotifyWithTemplate.Displayname, usersToNotifyWithTemplate.Subjects, usersToNotifyWithTemplate.Message); }