public async Task <ActionResult <string> > CreateDraftNotificationAsync([FromBody] DraftNotification notification) { if (notification == null) { throw new ArgumentNullException(nameof(notification)); } if (!notification.Validate(this.localizer, out string errorMessage)) { return(this.BadRequest(errorMessage)); } var containsHiddenMembership = await this.groupsService.ContainsHiddenMembershipAsync(notification.Groups); if (containsHiddenMembership) { return(this.Forbid()); } await this.UploadToBlobStorage(notification); notification.TrackingUrl = this.HttpContext.Request.Scheme + "://" + this.HttpContext.Request.Host + "/api/sentNotifications/tracking"; var notificationId = await this.notificationDataRepository.CreateDraftNotificationAsync( notification, this.HttpContext.User?.Identity?.Name); return(this.Ok(notificationId)); }
public async Task <ActionResult <string> > CreateDraftNotificationAsync([FromBody] DraftNotification notification) { if (!notification.Validate(this.localizer, out string errorMessage)) { return(this.BadRequest(errorMessage)); } // var containsHiddenMembership = await this.groupsService.ContainsHiddenMembershipAsync(notification.Groups); // if (containsHiddenMembership) // { // return this.Forbid(); // } var notificationId = await this.notificationDataRepository.CreateDraftNotificationAsync( notification, this.HttpContext.User?.Identity?.Name); return(this.Ok(notificationId)); }
public async Task <IActionResult> UpdateDraftNotificationAsync([FromBody] DraftNotification notification) { if (notification == null) { throw new ArgumentNullException(nameof(notification)); } var containsHiddenMembership = await this.groupsService.ContainsHiddenMembershipAsync(notification.Groups); if (containsHiddenMembership) { return(this.Forbid()); } if (!notification.Validate(this.localizer, out string errorMessage)) { return(this.BadRequest(errorMessage)); } var notificationEntity = new NotificationDataEntity { PartitionKey = NotificationDataTableNames.DraftNotificationsPartition, RowKey = notification.Id, Id = notification.Id, Title = notification.Title, ImageLink = notification.ImageLink, Summary = notification.Summary, Author = notification.Author, ButtonTitle = notification.ButtonTitle, ButtonLink = notification.ButtonLink, CreatedBy = this.HttpContext.User?.Identity?.Name, CreatedDate = DateTime.UtcNow, IsDraft = true, Teams = notification.Teams, Rosters = notification.Rosters, Groups = notification.Groups, AllUsers = notification.AllUsers, }; await this.notificationDataRepository.CreateOrUpdateAsync(notificationEntity); return(this.Ok()); }
public async Task <IActionResult> UpdateSentNotificationAsync([FromBody] DraftNotification notification) { var containsHiddenMembership = await this.groupsService.ContainsHiddenMembershipAsync(notification.Groups); if (containsHiddenMembership) { return(this.Forbid()); } if (!notification.Validate(this.localizer, out string errorMessage)) { return(this.BadRequest(errorMessage)); } var senttNotificationDataEntity = await this.notificationDataRepository.GetAsync( NotificationDataTableNames.SentNotificationsPartition, notification.Id); var updateSentNotificationDataEntity = new NotificationDataEntity { PartitionKey = NotificationDataTableNames.SentNotificationsPartition, RowKey = notification.Id, Id = notification.Id, Channel = notification.Channel, TemplateID = notification.TemplateID, Title = notification.Title, ImageLink = notification.ImageLink, Summary = notification.Summary, Author = notification.Author, ButtonTitle = notification.ButtonTitle, ButtonLink = notification.ButtonLink, CreatedBy = this.HttpContext.User?.Identity?.Name, CreatedDate = DateTime.UtcNow, SentDate = DateTime.UtcNow, Edited = DateTime.UtcNow, IsDraft = false, Teams = notification.Teams, Rosters = notification.Rosters, Groups = notification.Groups, AllUsers = notification.AllUsers, MessageVersion = senttNotificationDataEntity.MessageVersion, Succeeded = senttNotificationDataEntity.Succeeded, Failed = 0, Throttled = 0, TotalMessageCount = senttNotificationDataEntity.TotalMessageCount, SendingStartedDate = DateTime.UtcNow, Status = NotificationStatus.Sent.ToString(), }; var id = updateSentNotificationDataEntity.Id; var sentNotificationId = await this.notificationDataRepository.UpdateSentNotificationAsync(updateSentNotificationDataEntity, id); await this.sentNotificationUpdateDataRepository.EnsureSentNotificationDataTableExistsAsync(); var sendQueueMessageContent = new SendQueueMessageContent { NotificationId = sentNotificationId, ActivtiyId = null, RecipientData = null, NotificationUpdatePreviewEntity = new NotificationUpdatePreviewEntity { ActionType = "EditNotification", NotificationDataEntity = updateSentNotificationDataEntity, ConversationReferance = null, MessageActivity = null, ServiceUrl = null, AppID = null, }, }; await this.sendQueue.SendAsync(sendQueueMessageContent); return(this.Ok()); }