Exemplo n.º 1
0
        public List <Models.UserFlowAnswer> Resolve(Data.UserFlowNode source, Models.UserFlowNode destination, List <Models.UserFlowAnswer> member, ResolutionContext context)
        {
            member = new List <Models.UserFlowAnswer>();

            foreach (var userFlowAnswer in source.UserFlowAnswers)
            {
                var userValueString = userFlowAnswer.UserFlowAnswerValue;
                var userValueType   = userFlowAnswer.UserFlowAnswerType;

                IComparable userValue = userValueType switch
                {
                    FlowValueType.Number => decimal.Parse(userValueString),
                    FlowValueType.DateTime => DateTime.Parse(userValueString),
                    FlowValueType.Radio => userValueString,
                    FlowValueType.Select => userValueString,
                    FlowValueType.Checkbox => userValueString,
                    FlowValueType.Text => userValueString,
                    FlowValueType.TextArea => userValueString,
                    _ => throw new Exception()
                };

                var userFlowAnswerModel = new Models.UserFlowAnswer(userValue, userValueType);
                member.Add(userFlowAnswerModel);
            }

            return(member);
        }
    }
Exemplo n.º 2
0
        public async Task <Models.UserFlowNode> UpdateUserFlowNode(Models.UserFlowNode userNode)
        {
            var userNodeData = await context.UserFlowNodes.FindAsync(userNode.UserFlowNodeId);

            userNodeData.UserFlowAnswers = mapper.Map <UserFlowNode>(userNode).UserFlowAnswers;
            userNodeData.IsStale         = userNode.IsStale;
            await context.SaveChangesAsync();

            return(userNode);
        }
Exemplo n.º 3
0
        public async Task <Models.UserFlowNode> AddUserFlowNode(Models.UserFlowNode userNode)
        {
            var userNodeData = mapper.Map <UserFlowNode>(userNode);

            context.UserFlowNodes.Add(userNodeData);
            await context.SaveChangesAsync();

            userNode.UserFlowNodeId = userNodeData.UserFlowNodeId;
            return(userNode);
        }
        public List <Data.UserFlowAnswer> Resolve(Models.UserFlowNode source, Data.UserFlowNode destination, List <Data.UserFlowAnswer> member, ResolutionContext context)
        {
            member = new List <Data.UserFlowAnswer>();

            foreach (var userFlowAnswer in source.UserFlowAnswers)
            {
                var userValueString = userFlowAnswer.UserFlowAnswerValue.ToString();
                var userValueType   = userFlowAnswer.UserFlowAnswerType;

                var userFlowAnswerData = new Data.UserFlowAnswer()
                {
                    UserFlowAnswerValue = userValueString !, UserFlowAnswerType = userValueType
                };
                member.Add(userFlowAnswerData);
            }

            return(member);
        }
    }