public async Task <IActionResult> CreateNotification(string input) { var result = await taskExecutor.Execute(async() => { await createNotificationCommand.Execute(JsonConvert.DeserializeObject <CreateNotificationInputModel>(input)); }); if (result.ErrorMessage == null) { return(Ok()); } return(BadRequest(result.ErrorMessage)); }
private async Task NotifyManagers(User user, Department oldDepartment, Department newDepartment) { await createNotificationCommand.Execute(new CreateNotificationInputModel { DateTime = DateTime.UtcNow, Message = $"Employee {user.Name} was moved from {oldDepartment.Name} to {newDepartment.Name}", Repeat = RepeatInterval.Never, // little hack: // As we know that only managers can change department, then after validation we are sure that current users department is management // so we can send notification to management department TargetDepartments = new List <Guid> { userInfoProvider.CurrentDepartmentId } }); }