private async Task <List <HandlerServiceResult> > ConfigureCategoryDateRange(string answer, User user)
        {
            answer = answer.Trim();

            if (string.IsNullOrEmpty(answer))
            {
                return(new List <HandlerServiceResult>
                {
                    _resultService.BuildEmptyAnswerErrorResult()
                });
            }

            var category = await _categoryDocumentService.GetByIdAsync(user.Context.CategoryId);

            if (answer.Equals("All time"))
            {
                user.Context = null;

                await _userDocumentService.UpdateAsync(user);

                return(await _statsService.BuildStatistics(category));
            }

            try
            {
                var dateStrings = answer.Split('-');
                var from        = dateStrings[0].Split('.');
                var to          = dateStrings[1].Split('.');

                var fromDate = new DateTime(int.Parse(from[2]), int.Parse(from[1]), int.Parse(from[0]));
                var toDate   = new DateTime(int.Parse(to[2]), int.Parse(to[1]), int.Parse(to[0]));

                var operations = await _operationDocumentService.GetByCategoryId(category.Id);

                operations = operations.Where(o => o.Date >= fromDate && o.Date <= toDate).ToList();

                if (operations.Count == 0)
                {
                    return(new List <HandlerServiceResult>
                    {
                        _resultService.BuildStatsNoOperationsOnDateRangeErrorResult()
                    });
                }

                user.Context = null;
                await _userDocumentService.UpdateAsync(user);

                return(await _statsService.BuildStatistics(category, fromDate, toDate));
            }
            catch (Exception)
            {
                return(new List <HandlerServiceResult>
                {
                    _resultService.BuildOperationInvalidDateErrorResult()
                });
            }
        }
        private async Task <List <HandlerServiceResult> > ConfigureOperationCategory(string answer, User user)
        {
            answer = answer.Trim();

            if (string.IsNullOrEmpty(answer))
            {
                return(new List <HandlerServiceResult> {
                    _resultService.BuildEmptyAnswerErrorResult()
                });
            }

            var userCategories = await _documentServiceHelper.GetUserCategoriesByTypeAsync(user);

            var category = userCategories.FirstOrDefault(c => c.Name.Equals(answer));

            if (category == null)
            {
                return(new List <HandlerServiceResult> {
                    _resultService.BuildOperationCategoryNotFoundErrorResult()
                });
            }

            user.Context.CategoryId = category.Id;

            var operation = await GetOrCreateOperationAsync(user);

            operation.CategoryId = category.Id;

            await _documentServiceHelper.UpdateOperationAsync(operation);

            user.Context.CurrentNode = user.Context.CurrentNode.Children.FirstOrDefault();

            var nextQuestion = await _questionService.BuildQuestion(user);

            await _userDocumentService.UpdateAsync(user);

            return(new List <HandlerServiceResult> {
                nextQuestion
            });
        }