예제 #1
0
        public async Task <TaskItemView> CreateTask(TaskItemCreateDto taskItem)
        {
            var taskId = _taskRepository.Add(new TaskItemModel()
            {
                Name            = taskItem.TaskName.Trim(),
                PercentComplete = 0,
                Status          = StatusTask.WaitingToStart
            });
            var task = _taskRepository.GetTaskById(taskId);
            await _notifyService.SendToClient(taskItem.NotifyConnectionId, $"Вы поставили задачу '{taskItem.TaskName.Trim()}' в очередь");

            await _notifyService.SendExceptClient(taskItem.NotifyConnectionId, $"Добавлена новая задача '{taskItem.TaskName.Trim()}'");

            return(new TaskItemView()
            {
                Id = task.Id,
                Name = task.Name,
                PercentComplete = task.PercentComplete,
                Status = task.Status,
                StatusText = EnumDescription.GetDescription(task.Status)
            });
        }