Ejemplo n.º 1
0
        internal async Task UpdateTaskNotificationAsync(Abstractions.Models.Task task)
        {
            string content;
            var    recipients = new List <Guid>();


            var currentUser = await _identity.GetCurrentUserAsync();

            if (!currentUser.IsSuccess)
            {
                return;
            }

            if (currentUser.Result.Id == task.UserId)
            {
                var user = await _identity.UserManager.FindByNameAsync(task.Author);

                recipients.Add(user.Id);
                content = task.Status != TaskStatus.Completed ? string.Format(TaskUpdated, task.TaskNumber, currentUser.Result.UserName) : string.Format(TaskCompleted, task.TaskNumber, currentUser.Result.UserName);
            }
            else
            {
                recipients.Add(currentUser.Result.Id);
                content = string.Format(TaskUpdated, task.TaskNumber, task.Author);
            }

            await _notify.SendNotificationAsync(recipients,
                                                new Notification
            {
                Content            = content,
                Subject            = TaskTitle,
                NotificationTypeId = NotificationType.Info
            });
        }
Ejemplo n.º 2
0
 internal async Task DeleteTaskNotificationAsync(Abstractions.Models.Task task)
 {
     await _notify.SendNotificationAsync(new List <Guid>
     {
         task.UserId
     }, new Notification
     {
         Content            = string.Format(TaskRemoved, task.TaskNumber),
         Subject            = TaskTitle,
         NotificationTypeId = NotificationType.Info
     });
 }
Ejemplo n.º 3
0
        internal async Task AddTaskNotificationAsync(Abstractions.Models.Task task)
        {
            var listAssignedUserId = task.AssignedUsers.Select(s => s.UserId).ToList();

            await _notify.SendNotificationAsync(listAssignedUserId,
                                                new Notification
            {
                Content            = string.Format(TaskCreated, task.TaskNumber),
                Subject            = TaskTitle,
                NotificationTypeId = NotificationType.Info
            });
        }
Ejemplo n.º 4
0
        internal async Task ChangePriorityTaskNotificationAsync(Abstractions.Models.Task task, TaskPriority lastPriority)
        {
            var recipients      = task.AssignedUsers.Select(s => s.UserId).ToList();
            var taskUserRequest = await _identity.UserManager.FindByNameAsync(task.Author);

            if (taskUserRequest != null)
            {
                recipients.Add(taskUserRequest.Id.ToGuid());
            }
            recipients = recipients.Distinct().ToList();

            await _notify.SendNotificationAsync(recipients,
                                                new Notification
            {
                Content            = string.Format(TaskChangePriority, task.TaskNumber, lastPriority.ToString(), task.TaskPriority.ToString(), task.Author),
                Subject            = TaskTitle,
                NotificationTypeId = NotificationType.Info
            });
        }
Ejemplo n.º 5
0
        internal async Task DeleteTaskNotificationAsync(Abstractions.Models.Task task)
        {
            var listAssignedUserId = task.AssignedUsers.Select(s => s.UserId).ToList();
            var userRequest        = await _identity.UserManager.FindByNameAsync(task.Author);

            if (userRequest != null)
            {
                listAssignedUserId.Add(userRequest.Id.ToGuid());
            }

            listAssignedUserId = listAssignedUserId.Distinct().ToList();

            await _notify.SendNotificationAsync(listAssignedUserId,
                                                new Notification
            {
                Content            = string.Format(TaskRemoved, task.TaskNumber),
                Subject            = TaskTitle,
                NotificationTypeId = NotificationType.Info
            });
        }