protected async override Task OnInitializedAsync()
        {
            NotificationValues = await SessionStorageService.GetItemAsync <NotificationNames>(Id);

            DefaultSelectedNotificationType    = "Select Notification Type";
            DefaultSelectedNotificationChannel = "Select Notification Channel";
            if (!string.IsNullOrEmpty(Id))
            {
                var id = int.Parse(Id);
                if (id > 0)
                {
                    notificationTemplateCrtVM = await NotificationTemplateService.FetchByIdAsync(id);

                    NotificationId = notificationTemplateCrtVM.Id;

                    DefaultSelectedNotificationType       = NotificationValues.NotificationTypeName == null
                        ? DefaultSelectedNotificationType = "Select Notification Type" : NotificationValues.NotificationTypeName;

                    DefaultSelectedNotificationChannel       = NotificationValues.NotificationChannelName == null
                        ? DefaultSelectedNotificationChannel = "Select Notification Channel" : NotificationValues.NotificationChannelName;
                }

                notificationTypeVMs = await NotificationTypeService.FetchAllAsync();

                notificationChannelVMs = await NotificationChannelService.FetchAllAsync();
            }
        }
Ejemplo n.º 2
0
 public NotificationHelper(IUnitOfWork unitOfWork)
 {
     _unitOfWork              = unitOfWork;
     _employeeService         = new EmployeeService(_unitOfWork);
     _notificationTypeService = new NotificationTypeService(_unitOfWork);
     _userService             = new UserService(_unitOfWork);
 }
Ejemplo n.º 3
0
        public async Task PutAsyncTest()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            NotificationType nt    = new NotificationType();
            var notificationTypeId = 1;

            nt.Id = notificationTypeId; nt.Description = "Announcement: 30 minutes to start the class";

            NotificationType expected = new NotificationType();

            expected.Description = "Announcement out of date";

            mockNotificationTypeRepository.Setup(r => r.FindById(notificationTypeId))
            .Returns(Task.FromResult <NotificationType>(nt));

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.UpdateAsync(notificationTypeId, expected);

            // Assert
            Assert.AreEqual(expected.Description, result.Resource.Description);
        }
 protected async Task CrtOrUptNotificationType()
 {
     if (NotificationId > 0)
     {
         await NotificationTypeService.UpdateAsync(NotificationTypeCrt);
     }
     else
     {
         await NotificationTypeService.CreateAsync(NotificationTypeCrt);
     }
     navigationManager.NavigateTo("/notificationtypes");
 }
        protected async override Task OnInitializedAsync()
        {
            if (!string.IsNullOrEmpty(Id))
            {
                var id = int.Parse(Id);
                if (id > 0)
                {
                    NotificationTypeCrt = await NotificationTypeService.FetchByIdAsync(id);

                    NotificationId = NotificationTypeCrt.Id;
                }
            }
        }
Ejemplo n.º 6
0
        public async Task GetAsyncTestUnhappy()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            var notificationTypeId = 1;

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.GetByIdAsync(notificationTypeId);

            var message = result.Message;

            // Assert
            message.Should().Be("Notification type not found");
        }
        protected async Task DeleteNotificationType(int id)
        {
            bool?result = await DialogService.Confirm("Are you sure?", "DELETE NOTIFICATION TYPE", new ConfirmOptions()
            {
                OkButtonText = "Yes", CancelButtonText = "No", ShowClose = false
            });

            if (result.Value == true)
            {
                var deletedNotification = await NotificationTypeService.DeleteAsync(id);

                if (deletedNotification > 0)
                {
                }
                else
                {
                }
            }
        }
Ejemplo n.º 8
0
        public async Task PostAsyncTestHappy()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            NotificationType nt    = new NotificationType();
            var notificationTypeId = 1;

            nt.Id = notificationTypeId;

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.SaveAsync(nt);

            // Assert
            Assert.AreEqual(nt, result.Resource);
        }
Ejemplo n.º 9
0
        public async Task DeleteAsyncTestHappy()
        {
            // Arrange
            var mockNotificationTypeRepository = GetDefaultINotificationTypeRepositoryInstance();
            var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance();

            NotificationType nt    = new NotificationType();
            var notificationTypeId = 1;

            nt.Id = notificationTypeId;

            mockNotificationTypeRepository.Setup(r => r.FindById(notificationTypeId))
            .Returns(Task.FromResult <NotificationType>(nt));

            var service = new NotificationTypeService(mockNotificationTypeRepository.Object, mockIUnitOfWork.Object);

            // Act
            NotificationTypeResponse result = await service.DeleteAsync(notificationTypeId);

            // Assert
            Assert.AreEqual(nt, result.Resource);
        }
 protected async override Task OnInitializedAsync()
 {
     notificationTypevm = await NotificationTypeService.FetchAllAsync();
 }