예제 #1
0
        public async Task <MessageOutputBase> Lists(GetUserListsRequest request)
        {
            MessageOutputBase result = null;

            request.ForUserName = GetCurrentUser();
            request.ForUserId   = GetCurrentUserId();

            await Execute(flow =>
            {
                flow.StartRegisterFlow()
                .Add <CheckUserExistsStep>()
                .Add <FetchUserListsStep>();

                flow.
                When <UserNotFoundStep, UserNotFoundParams>((notFound) =>
                {
                    result = notFound.Response;
                })
                .When <FetchUserListsStep, FetchUserListsParams>((fetch) =>
                {
                    result = fetch.ListsResponse;
                });
            }, request,
                          error =>
            {
                result = error;
            });

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Производит резолвинг данных с текущим контекстом.
        /// </summary>
        /// <param name="context">Контекст.</param>
        /// <returns>Данные.</returns>
        public override async Task <object> Resolve(ResolveFieldContext <object> context)
        {
            var request = new GetUserListsRequest();

            request.UserName           = context.GetArgument <string>("userName");
            request.LastListId         = context.GetArgument <string>("lastListId");
            request.SelectedListNumber = context.GetArgument <string>("selectedListNumber");
            request.ForUserName        = context.UserContext.As <UserContext>().UserName;
            request.ForUserId          = context.UserContext.As <UserContext>().UserId;

            MessageOutputBase outputMessage = null;

            await Execute(flow =>
            {
                flow.StartRegisterFlow()
                .Add <CheckUserExistsStep>()
                .Add <FetchUserListsStep>();

                flow.
                When <UserNotFoundStep, UserNotFoundParams>((notFound) =>
                {
                    outputMessage = notFound.Response;
                })
                .When <FetchUserListsStep, FetchUserListsParams>((fetch) =>
                {
                    outputMessage = fetch.ListsResponse;
                });
            }, request,
                          context);

            ProcessErrors(context, outputMessage);

            return(outputMessage);
        }