예제 #1
0
        public IActionResult Notifications()
        {
            try
            {
                var CurrentUser = _context.Users.Find(userManager.GetUserId(User));
                if (CurrentUser is null)
                {
                    throw new DomainException(ErrorMessages.NotSignedIn);
                }

                var existingAccount = _userStore.GetByIdentityUserId(CurrentUser.Id);
                if (existingAccount.AccountStatus.Equals(Status.Suspended))
                {
                    signInManager.SignOutAsync();
                }

                var GetAllNotifications = new GetAllNotificationsQuery(_userStore, _notificationBox, existingAccount, CurrentUser);
                return(View(GetAllNotifications.Handle()));
            }
            catch (DomainException ex)
            {
                _logger.LogError(ex.Message);
                return(RedirectToAction(ActionName.Login));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(RedirectToAction("ServerError"));
            }
        }
예제 #2
0
        public async Task <List <NotificationVm> > Handle(GetAllNotificationsQuery request,
                                                          CancellationToken cancellationToken)
        {
            var notifications = await _context.Notifications.OrderByDescending(f => f.Created)
                                .ToListAsync(cancellationToken);

            return(notifications.Select(notification => new NotificationVm
            {
                Created = notification.Created,
                Id = notification.Id,
                Text = notification.Type switch
                {
                    NotificationType.Applicant => "ثبت درخواست نامه",
                    NotificationType.Purchase => "ثبت خرید",
                    NotificationType.Sell => "ثبت فروش",
                    NotificationType.Tell => "ثبت تلفن ثابت",
                    NotificationType.Ticket => "ثبت تیکت",
                    NotificationType.BankCard => "ثبت کارت بانکی",
                    NotificationType.NationalCard => "ثبت کارت ملی",
                    _ => ""
                },