コード例 #1
0
        public List <GroupFunctionViewModel> GetGroupFunctions()
        {
            var functions = new GetFunctionsQueryHandler(new DataBaseContext()).Handle(new GetFunctionsQuery
            {
                ForSpy = false
            });

            var groups         = new GetGroupsQueryHandler(new DataBaseContext()).Handle(new GetGroupsQuery());
            var groupFunctions = new GroupFunctionsQueryHandler(new DataBaseContext()).Handle(new GroupFunctionsQuery());

            var result = groups.Select(group => new GroupFunctionViewModel
            {
                GroupId   = group.Id,
                GroupName = group.Name,
                Functions = functions.Select(function => new FunctionViewModel
                {
                    Name         = function.Name,
                    FunctionName = function.FunctionName,
                    FunctionId   = function.FunctionId,
                    Assigned     =
                        groupFunctions.Any(
                            groupFunction =>
                            groupFunction.FunctionId == function.FunctionId && groupFunction.GroupId == group.Id),
                    FunctionTypeName = function.FunctionTypeName,
                    TypeName         = function.TypeName
                }).ToList()
            }).ToList();

            return(result);
        }
コード例 #2
0
        public GroupList GetGroups()
        {
            var groups = new GetGroupsQueryHandler(new DataBaseContext()).Handle(new GetGroupsQuery());

            return(new GroupList
            {
                Groups = groups.Select(data => new Group
                {
                    Id = data.Id,
                    Name = data.Name
                }).ToList()
            });
        }
コード例 #3
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);
        }