public object Get(GetNotifications request)
        {
            var result = _notificationsRepo.GetNotifications(new NotificationQuery
            {
                IsRead     = request.IsRead,
                Limit      = request.Limit,
                StartIndex = request.StartIndex,
                UserId     = request.UserId
            });

            return(ToOptimizedResult(result));
        }
        public List <NotificationsEntity> GetNotifications(int NPINumber)
        {
            try
            {
                //int noteID = 1622602;

                List <NotificationsEntity> notifications = new List <NotificationsEntity>();
                notifications = _notificationsRepository.GetNotifications(NPINumber);
                if (notifications.Count < 1)
                {
                    throw new ApiDataException(1001, "No notification found for this id.", HttpStatusCode.NotFound);
                }
                return(notifications);
            }
            catch (Exception ex)
            {
                throw new ApiDataException(1001, "No notification found for this id.", HttpStatusCode.NotFound);
                //  throw new ApiException() { ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = "Bad Request..." };

                //throw new Exception("No product found for this id");
            }
        }
Пример #3
0
 public List <Notification> GetNotifications(string userId, int?count)
 {
     return(NotificationsRepository.GetNotifications(userId, count));
 }
Пример #4
0
        public List <ResultNotificationsDto> SummaryNotifications(long idApplication, string username, int?specificGroup, long?idNotificationType, bool summaryView, bool onlyMainNotification)
        {
            long?idUser = null;
            List <ResultNotificationsDto> listNotificationsDto = new List <ResultNotificationsDto>();
            List <AssociateUsersGroupDto> listgroup            = new List <AssociateUsersGroupDto>();

            if (!string.IsNullOrEmpty(username))
            {
                List <UserApplicationDto> listUser = UserApplicationRepository.GetUserApplication(new UserApplicationDto()
                {
                    UserName = username
                });
                if (listUser.Count() == 0)
                {
                    return(new List <ResultNotificationsDto>());
                }
                else
                {
                    idUser    = listUser.First().IdUserApplication.Value;
                    listgroup = AssociateUsersGroupRepository.GetAssociateUsersGroup(new AssociateUsersGroupDto()
                    {
                        IdUserApplication = idUser, IdUserGroup = specificGroup
                    });
                }
            }

            List <NotificationsSettingsDto> listConfigNoti = new List <NotificationsSettingsDto>();

            //IdUserGroup = 0 All User Group
            listConfigNoti.Add(new NotificationsSettingsDto()
            {
                IdApplication = idApplication, IdUserGroup = 0, Active = true
            });
            if (idUser != null)
            {
                listConfigNoti.Add(new NotificationsSettingsDto()
                {
                    IdApplication = idApplication, IdUserApplication = idUser, Active = true
                });
            }

            listgroup.ForEach(data =>
            {
                listConfigNoti.Add(new NotificationsSettingsDto()
                {
                    IdApplication = idApplication, IdUserGroup = data.IdUserGroup, Active = true
                });
            });


            listConfigNoti = NotificationsSettingsRepository.GetUpdateNotifications(listConfigNoti, summaryView);

            if (onlyMainNotification == true)
            {
                idNotificationType = (long)EnumReferenceTable.MainNotifications;
            }

            List <NotificationsDto> listNoti = new List <NotificationsDto>();

            listConfigNoti.Select(data => data.IdNotification).Distinct().ToList().ForEach(data =>
            {
                listNoti.Add(new NotificationsDto()
                {
                    IdNotification = data, IdNotificationType = idNotificationType
                });
            });

            if (listNoti.Count > 0)
            {
                listNotificationsDto = NotificationsRepository.GetNotifications(listNoti).Select(Mapper.Map <NotificationsDto, ResultNotificationsDto>).ToList();
            }

            if (onlyMainNotification != true)
            {
                listNotificationsDto.RemoveAll(filter => filter.IdNotificationType == (long)EnumReferenceTable.MainNotifications);
            }

            return(listNotificationsDto);
        }