Ejemplo n.º 1
0
        public MessageListModel GetMessagesList(long?accountId, long?groupId)
        {
            var messages = new GetMessageModelQueryHandler(new DataBaseContext()).Handle(new GetMessageModelQuery
            {
                AccountId = accountId,
                GroupId   = groupId
            });

            var groups = new GetGroupsQueryHandler(new DataBaseContext())
                         .Handle(new GetGroupsQuery())
                         .Select(data => new Group
            {
                Id   = data.Id,
                Name = data.Name
            }).ToList();


            if (groupId == null && accountId != null)
            {
                var account = _accountManager.GetAccountById((long)accountId);
                groupId =
                    new GetGroupIdByFacebookIdQueryHandler(new DataBaseContext()).Handle(
                        new GetGroupIdByFacebookIdQuery
                {
                    FacebookId = account.FacebookId
                });
            }

            var result = new MessageListModel
            {
                Messages = messages.Select(model => new MessageListItemModel
                {
                    Message          = model.Message,
                    OrderNumber      = model.OrderNumber,
                    StartTime        = model.StartTime,
                    EndTime          = model.EndTime,
                    IsEmergencyText  = model.IsEmergencyText,
                    ImportancyFactor = model.ImportancyFactor,
                    IsBotFirst       = model.MessageRegime == MessageRegime.BotFirstMessage,
                    Id = model.Id
                }).ToList(),
                AccountId = accountId,
                GroupId   = groupId,
                GroupList = new GroupList
                {
                    Groups = groups
                }
            };

            return(result);
        }
Ejemplo n.º 2
0
        public bool HasPermissionsByFacebookId(FunctionName functionName, long facebookId)
        {
            var groupId = new GetGroupIdByFacebookIdQueryHandler(new DataBaseContext()).Handle(new GetGroupIdByFacebookIdQuery
            {
                FacebookId = facebookId
            });

            if (groupId == null)
            {
                return(false);
            }

            return(HasPermissions(functionName, groupId.Value));
        }