public async Task <UserNotification> Update(UserNotificationUpdateModel notificationInput)
        {
            var userNotification = _context.UserNotifications.
                                   Find(notificationInput.Id);

            if (userNotification == null)
            {
                throw new AppException("User Notification data not found");
            }
            else
            {
                userNotification.EmailNotification = notificationInput.EmailNotification;
                userNotification.AppNotification   = notificationInput.AppNotification;

                if (notificationInput.EmailNotification || notificationInput.AppNotification)
                {
                    userNotification.Hours = notificationInput.Hours;
                }

                _context.UserNotifications.Update(userNotification);
                await _context.SaveChangesAsync();

                return(userNotification);
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <UserNotification> > PutUserNotification(UserNotificationUpdateModel notificationInput)
        {
            var result = await _userNotificationService.Update(notificationInput);

            return(result);
        }