public async System.Threading.Tasks.Task Create(CreateTaskInput input) { var task = ObjectMapper.Map <Task>(input); await _taskRepository.InsertAsync(task); if (input.AssignedPersonId.HasValue) { var targetTask = await _taskRepository .GetAll() .Include(t => t.AssignedPerson) .WhereIf(input.AssignedPersonId.HasValue, t => t.AssignedPersonId == input.AssignedPersonId.Value) .OrderByDescending(t => t.CreationTime) .ToListAsync(); await _emailManager.Assign(new TaskListDto() { Title = input.Title, AssignedPersonName = targetTask[0].AssignedPerson.Name }, "*****@*****.**"); } }