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); }
public IActionResult Put(string id, [FromBody] EmailNotificationDto t) { ApplicationUser user = GetUserIncludingCerts(id); EmailNotification notification = user.AddNotification(t, _userManager, _mediator).Result; if (notification != null) { return(Ok(notification.Id)); } else { return(BadRequest()); } }
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); } }
/// <summary> /// Emails notification to the user /// </summary> /// <param name="dto"></param> /// <returns></returns> public bool EmailNotification(EmailNotificationDto dto) { var response = SendSystemEmail(dto); return response.IsSuccessful; }