Example #1
0
        public async Task MarkNotificationAsRead(Guid notificationId)
        {
            var notification = await _notificationsContext.Notifications.FindAsync(notificationId);

            _notificationsContext.Remove(notification);
            await _notificationsContext.SaveChangesAsync();
        }
Example #2
0
        public virtual async Task CreateNotificationProfile(NotificationProfileModelDto dto)
        {
            #region Profile

            var entity = new NotificationProfile()
            {
                Id   = dto.Id,
                Name = dto.Name
            };
            await _notificationsContext.NotificationProfiles.AddAsync(entity);

            #endregion

            #region Users

            var users = dto.Users.Select(id => new NotificationUser()
            {
                UserId = id, NotificationProfileId = entity.Id
            }).ToList();
            await _notificationsContext.NotificationUsers.AddRangeAsync(users);

            #endregion

            #region profileEvents

            var profileEvents = dto.Events.Select(id => new NotificationEvent()
            {
                EventId = id, NotificationProfileId = entity.Id
            }).ToList();
            await _notificationsContext.NotificationEvents.AddRangeAsync(profileEvents);

            #endregion

            await _notificationsContext.SaveChangesAsync();
        }
Example #3
0
        public virtual async Task CreateHtmlEventMarkup(HtmlEventMarkupModelDto model)
        {
            var entity = new HtmlEventMarkup()
            {
                Id            = Guid.NewGuid(),
                Name          = model.Name,
                Subject       = model.Subject,
                Subtitle      = model.Subtitle,
                ChangesMarkup = model.ChangesMarkup,
                EventId       = model.EventId
            };
            await _notificationsContext.HtmlEventMarkups.AddAsync(entity);

            var eventEntity = await _notificationsContext.Events.FindAsync(entity.EventId);

            if (eventEntity == null)
            {
                throw new NotFoundException(typeof(Event).Name, entity.EventId.ToString());
            }
            eventEntity.HtmlEventMarkupId = entity.Id;

            _notificationsContext.Events.Update(eventEntity);
            await _notificationsContext.SaveChangesAsync();
        }
Example #4
0
        public virtual async Task CreateEvent(string eventName)
        {
            if (_notificationsContext.Events.Any(x => x.EventName == eventName))
            {
                return;
            }

            await _notificationsContext.AddAsync(new Event()
            {
                Id        = Guid.NewGuid(),
                EventName = eventName,
            });

            await _notificationsContext.SaveChangesAsync();
        }