Beispiel #1
0
        /// <summary>
        /// SaveField Value ByUser
        /// </summary>
        /// <param name="fieldsValueByUserFlow">fields Value ByUser Flow</param>
        /// <returns>Is Save</returns>
        private bool SaveFieldValueByUser(FieldsValueByUserFlow fieldsValueByUserFlow)
        {
            var result       = true;
            var fieldsByUser = new FieldsByUser(this.RepositoryContext);

            foreach (FieldsValue fieldsValue in fieldsValueByUserFlow.fieldsValue)
            {
                var idFields = fieldsByUser.CreateAsync(GetFieldsByUser(fieldsValueByUserFlow, fieldsValue));
                if (idFields.Result == null)
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Get Steps By Flow
        /// </summary>
        /// <param name="steps">steps</param>
        /// <param name="idUser">idUser</param>
        /// <returns>List Steps General</returns>
        private List <StepsGeneral> GetStepsByFlow(List <Entities.Secuences> steps, int?idUser)
        {
            var flowSteps = new List <StepsGeneral>();

            steps.ForEach(delegate(Entities.Secuences step)
            {
                var stepsNext     = GetStepsNext(step);
                var stepsInFields = new StepsInFields(RepositoryContext).ToListAsync(x => x.IdStep == step.IdStep);
                if (stepsInFields.Result == null)
                {
                    ThrowExceptionField();
                }
                List <FieldGeneral> fieldsByStep = GetFildGeneralBySteps(stepsInFields.Result);
                if (idUser != null)
                {
                    var listFields = new List <int>();
                    fieldsByStep.ForEach(delegate(FieldGeneral field)
                    {
                        listFields.Add(field.Id);
                    }
                                         );
                    var fieldsByUser = new FieldsByUser(RepositoryContext).ToListAsync
                                       (
                        x => x.IdUser.Equals(idUser) && listFields.Contains(x.IdField)
                                       );
                    var listFieldsNotExist = new List <int>();
                    fieldsByUser.Result.ForEach(delegate(Entities.FieldsByUser field)
                    {
                        listFieldsNotExist.Add(field.IdField);
                    }
                                                );
                    if (fieldsByUser.Result != null)
                    {
                        fieldsByStep = fieldsByStep.Where(x => !listFieldsNotExist.Contains(x.Id)).ToList();
                    }
                }
                flowSteps.Add(GetStepsGeneral(step, stepsNext, fieldsByStep));
            });
            return(flowSteps);
        }