예제 #1
0
 public NotificationsView(NotificationListViewModel model)
 {
     InitializeComponent();
     DataContext = model;
     _ViewModel  = new NotificationListViewModel();
     CustomGridLines.ItemsSource = DataGridTableCollection.GridLines(8, 50).AsEnumerable();
 }
예제 #2
0
        public virtual PartialViewResult List()
        {
            var notificationListPage = _notificationContentProvider.GetNotificationListPage();
            var itemsCountForPopup   = notificationListPage.GetPropertyValue(NotificationConstants.ItemCountForPopupPropertyTypeAlias, default(int));

            var(notifications, _) = _uiNotifierService.GetMany(_intranetMemberService.GetCurrentMemberId(), itemsCountForPopup);

            var notificationsArray = notifications.ToArray();

            var notNotifiedNotifications = notificationsArray.Where(el => !el.IsNotified).ToArray();

            if (notNotifiedNotifications.Length > 0)
            {
                _uiNotifierService.Notify(notNotifiedNotifications);
            }

            var notificationsViewModels = notificationsArray.Take(itemsCountForPopup).Select(MapNotificationToViewModel).ToArray();

            var result = new NotificationListViewModel
            {
                Notifications  = notificationsViewModels,
                BlockScrolling = false
            };

            return(PartialView(ListViewPath, result));
        }
예제 #3
0
        public virtual ActionResult Index(int page = 1)
        {
            var take = page * ItemsPerPage;

            var(notifications, totalCount) = _uiNotifierService.GetMany(_intranetMemberService.GetCurrentMemberId(), take);

            var notificationsArray = notifications.ToArray();

            var notNotifiedNotifications = notificationsArray.Where(el => !el.IsNotified).ToArray();

            if (notNotifiedNotifications.Length > 0)
            {
                _uiNotifierService.Notify(notNotifiedNotifications);
            }

            var notificationsViewModels = notificationsArray.Select(MapNotificationToViewModel).ToArray();

            var result = new NotificationListViewModel
            {
                Notifications  = notificationsViewModels,
                BlockScrolling = totalCount <= take
            };

            return(PartialView(ListViewPath, result));
        }
        public ActionResult Index()
        {
            var subBrandId = GetCurrentSubBrandId();
            var subBrand   = _brandService.GetSubBrandById(subBrandId);
            var uvm        = SecurityHelpers.GetUserViewModel();

            var model = new NotificationListViewModel()
            {
                SubBrandId     = subBrand.SubBrandID,
                isEmailEnabled = subBrand.EmailEnabled,
                EmailSendTime  = TimespanToString(subBrand.EmailSendTime),
                isCallEnabled  = subBrand.CallEnabled,
                CallSendTime   = TimespanToString(subBrand.CallSendTime),
                CanEdit        = CanEditNotification(uvm.IsAdmin)
            };

            var statusList = _centerService.GetCenterStatus();

            foreach (var status in statusList)
            {
                model.StoreStatusList.Add(new SelectListItem()
                {
                    Text = status.CenterStatusDescription.ToString(), Value = status.CenterStatusID.ToString()
                });
            }

            return(View(model));
        }
예제 #5
0
        public async Task <ActionResult> Index(string tabId, int parentId)
        {
            var result = _notificationService.InitList(parentId);
            var model  = NotificationListViewModel.Create(result, tabId, parentId);

            return(await JsonHtml("Index", model));
        }
        public async Task GetNotifications_ReturnedRedirectResult_CorrectScenario()
        {
            //Arrange
            var noti = new NotificationListViewModel();

            mockUserManager.Setup(s => s.FindByNameAsync(It.IsAny <string>())).ReturnsAsync(new ApplicationUser());
            mockUserManager.Setup(s => s.IsInRoleAsync(new ApplicationUser(), It.IsAny <string>())).ReturnsAsync(() => true);

            //Act
            var result = await _controller.GetNotifications(noti, "test");

            //Assert
            Assert.IsType <RedirectResult>(result);
        }
        public async Task GetNotifications_ReturnedRedirectToActionResult_ForUnFindedUser()
        {
            //Arrange
            var noti = new NotificationListViewModel();

            mockUserManager.Setup(s => s.FindByNameAsync(It.IsAny <string>())).ReturnsAsync(() => null);
            //Act
            var result = await _controller.GetNotifications(noti, "test");

            //Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Error", redirectToActionResult.ActionName);
            Assert.Equal("Error", redirectToActionResult.ControllerName);
        }
        public async Task GetNotifications_ReturnedRedirectToActionResult_ForInValidModel()
        {
            //Arrange
            var noti = new NotificationListViewModel();

            _controller.ModelState.AddModelError("error", "some error");
            //Act
            var result = await _controller.GetNotifications(noti, "test");

            //Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Error", redirectToActionResult.ActionName);
            Assert.Equal("Error", redirectToActionResult.ControllerName);
        }
예제 #9
0
        public MainPageViewModel()
        {
            //this should be initiaized within IoC
            _notificationManager = new NotificationManager();
            _dispatcherHelper    = new DispatcherHelper();

            NotificationListViewModel = new NotificationListViewModel(_notificationManager, _dispatcherHelper);

            DisplayNotificationCommand                      = new Relay_Command(DisplayNotificationCommandExecute);
            DisplayDataTemplateNotificationCommand          = new Relay_Command(DisplayDataTemplateNotificationCommandExecute);
            DisplayDataTemplateNotificationNoDismissCommand = new Relay_Command(DisplayDataTemplateNotificationNoDismissCommandExecute);
            DisplayErrorTypeNotificationCommand             = new Relay_Command(DisplayErrorTypeNotificationCommandExecute);
            DisplayInfoTypeNotificationCommand              = new Relay_Command(DisplayInfoTypeNotificationCommandExecute);
            DissmissAllNotificationsCommand                 = new Relay_Command(DissmissAllNotificationsCommandExecute);
        }
예제 #10
0
        public async Task <ActionResult> Index(NotificationListViewModel model)
        {
            Task <int> count = _notificationRepository.GetTotalCountAsync((int)_contextService.CurrentUserAccountId);
            Task <IEnumerable <NotificationAggregate> > aggregates = _notificationRepository.GetAggregatesAsync((int)_contextService.CurrentUserAccountId);

            await Task.WhenAll(count, aggregates);

            var result = new NotificationListViewModel {
                Total         = await count,
                Notifications = await aggregates,
                Page          = model.Page,
                Token         = model.Token
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public async Task <IActionResult> GetNotifications(string name)
        {
            if (name == null)
            {
                return(RedirectToAction("Welcome", "Success"));
            }

            var user = await _userManager.FindByNameAsync(name);

            List <NotificationViewModel> returnedList = new List <NotificationViewModel>();
            var notiList = new NotificationListViewModel();

            if (await _userManager.IsInRoleAsync(user, "Employee"))
            {
                var notis = _notificationRepository.GetNotificationsForEmployee(user.Id);
                notis.ForEach(n =>
                {
                    returnedList.Add(_mapper.MapEmployeeNotificationsToNotificationViewModel(n));
                });
                notiList.NotificationList = returnedList;
                return(View("Notifications", notiList));
            }
            else if (await _userManager.IsInRoleAsync(user, "Admin"))
            {
                var notis = _notificationRepository.GetNotificationsForAdmin(ERole.Admin);
                notis.ForEach(n =>
                {
                    returnedList.Add(_mapper.MapAdminNotificationsToNotificationViewModel(n));
                });
                notiList.NotificationList = returnedList;
                return(View("Notifications", notiList));
            }
            else if (await _userManager.IsInRoleAsync(user, "Client"))
            {
                var notis = _notificationRepository.GetNotificationsForClient(user.Id);
                notis.ForEach(n =>
                {
                    returnedList.Add(_mapper.MapClientNotificationsToNotificationViewModel(n));
                });
                notiList.NotificationList = returnedList;
                return(View("Notifications", notiList));
            }
            else
            {
                return(RedirectToAction("Error", "Error"));
            }
        }
예제 #12
0
        public NotificationListViewModel PrepareNotificationListViewModel(List <Notification> notifications = null)
        {
            if (notifications == null)
            {
                throw new ArgumentNullException(nameof(notifications));
            }

            var notificationListViewModel = new NotificationListViewModel();

            foreach (var notification in notifications)
            {
                var notificationViewModel = _mapper.Map <NotificationViewModel>(notification);
                notificationListViewModel.NotificationList.Add(notificationViewModel);
            }

            return(notificationListViewModel);
        }
 public IHttpActionResult Delete(NotificationListViewModel Notifications)
 {
     try
     {
         using (AppDBContext context = new AppDBContext())
         {
             var repo = new NotificationRepository(context);
             repo.DeleteList(Notifications.Ids);
         }
         return(Ok());
     }
     catch (Exception ex)
     {
         Logger.Log(typeof(NotificationController), ex.Message + ex.StackTrace, LogType.ERROR);
         return(InternalServerError());
     }
 }
예제 #14
0
        public NotificationListViewModel retrieveNotificationsListViewModel()
        {
            retrieveNotifications();

            if (m_notifs.Any())
            {
                foreach (var notif in m_notifs)
                {
                    CreateNotificationViewModel(notif);
                }
            }

            NotificationListViewModel nlvm = new NotificationListViewModel();

            nlvm.m_nlvm = m_notifsViewModels.OrderByDescending(n => n.ID).ToList();

            return(nlvm);
        }
        public async Task <IActionResult> GetNotifications(NotificationListViewModel noti, string userName)
        {
            if (ModelState.IsValid && userName != null)
            {
                var readedNotifications = noti.NotificationList.Where(s => s.IsRead == true).ToList();

                var user = await _userManager.FindByNameAsync(userName);

                if (user != null)
                {
                    if (await _userManager.IsInRoleAsync(user, "Employee"))
                    {
                        readedNotifications.ForEach(f =>
                        {
                            _notificationRepository.SetNotificationForEmployeeAsRead(f.NotiId);
                        });
                    }
                    if (await _userManager.IsInRoleAsync(user, "Admin"))
                    {
                        readedNotifications.ForEach(f =>
                        {
                            _notificationRepository.SetNotificationForAdminAsRead(f.NotiId);
                        });
                    }
                    if (await _userManager.IsInRoleAsync(user, "Client"))
                    {
                        readedNotifications.ForEach(f =>
                        {
                            _notificationRepository.SetNotificationForClientAsRead(f.NotiId);
                        });
                    }
                    return(Redirect("GetNotifications?name=" + userName));
                }
                return(RedirectToAction("Error", "Error"));
            }
            return(RedirectToAction("Error", "Error"));
        }
예제 #16
0
 //public NotificationsPage()
 //{
 //    InitializeComponent();
 //    BindingContext = new NotificationListViewModel();
 //}
 public NotificationsPage(NotificationListViewModel plvm)
 {
     InitializeComponent();
     ViewModel           = plvm;
     this.BindingContext = ViewModel;
 }