Esempio n. 1
0
        public async Task <IActionResult> RegisterAsync([FromBody] AccountRegisterRequest request, [FromServices] INotifier <UserCheckin> notifier)
        {
            try
            {
                var profile = new UserProfile
                {
                    User = new User
                    {
                        Name        = request.Email,
                        CreatedOver = request.UIClientId
                    },
                    Email       = request.Email,
                    DisplayName = request.Email,
                    CompanyName = request.Company,
                    ManagerName = request.ManagerName,
                };
                var userCheckin = await _repo.RegisterAccountAsync(profile);

                await notifier.CreateNotificationAsync(userCheckin);

                await _repo.MarkUserCheckinNotifiedAsync(userCheckin);

                return(Ok());
            }
            catch (UserAccountException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"error Register {this.GetType().Name}");
                return(InternalServerError(ex));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> RemindAsync([FromBody] string userName, [FromServices] INotifier <UserCheckin> notifier)
        {
            try
            {
                var userCheckin = await _repo.RemindAccountAsync(userName);

                await notifier.CreateNotificationAsync(userCheckin);

                await _repo.MarkUserCheckinNotifiedAsync(userCheckin);

                return(Ok());
            }
            catch (UserAccountException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"error {nameof(AccountController.RemindAsync)} {this.GetType().Name}");
                return(InternalServerError(ex));
            }
        }