コード例 #1
0
        private EmailNotification NotificationFromDto(EmailNotificationDto dto)
        {
            EmailNotification notification = new EmailNotification();

            notification.DestinationEmail = Email;
            notification.Body             = dto.Body;
            notification.Subject          = dto.Subject;
            notification.User             = this;
            notification.UserId           = this.Id;
            notification.ActivationDate   = new DateTime();

            return(notification);
        }
コード例 #2
0
        public async Task <EmailNotification> AddNotification(EmailNotificationDto not, UserManager <ApplicationUser> _userManager, IMediator _mediator)
        {
            EmailNotification notification = NotificationFromDto(not);

            //Default Activation Date to right now for the time being.
            notification.ActivationDate = DateTime.UtcNow;

            EmailNotifications.Add(notification);
            Task <IdentityResult> result = _userManager.UpdateAsync(this);

            if (result.Result.Succeeded)
            {
                notification.Created(_mediator);
                return(notification);
            }
            else
            {
                return(null);
            }
        }