예제 #1
0
        public FrageModel(question frage)
        {
            this.Id = frage.Id;
            this.FrageText = frage.FrageText;
            this.Category = frage.Type.Equals("student") ? "Schüler" : "Lehrer";
            this.Informal = this.Category.Equals("Schüler");

            using (umfrageDB db = new umfrageDB())
            {
                switch (frage.Sex)
                {
                    case 'm':
                        this.NameZusatz = frage.Type.Equals("students") ? ", Jungen" : ", Männer";
                        break;
                    case 'f':
                        this.NameZusatz = frage.Type.Equals("students") ? ", Mädchen" : ", Frauen";
                        break;
                }

                this.Options = (from option in db.options
                    where option.type.Equals(frage.Type) && option.sex.Equals(frage.Sex)
                    select new OptionModel(option)).ToArray().OrderBy(model =>
                    {
                        string[] lName = model.Name.Split(' ');
                        return this.Informal ? model.Name : lName[lName.Length - 1];
                    });
            }
        }
예제 #2
0
        public PairModel(question frage)
        {
            this.Id = frage.Id;
            this.FrageText = frage.FrageText;
            this.Category = frage.Type.Equals("student") ? "Schüler" : "Lehrer";
            this.Informal = this.Category.Equals("Schüler");

            using (umfrageDB db = new umfrageDB())
            {
                this.Male = (from option in db.options
                    where option.type.Equals(frage.Type) && option.sex.Equals('m')
                    select new OptionModel(option)).ToArray()
                    .OrderBy(model => this.Informal ? model.Name : model.Name.Split(' ')[1]);

                this.Female = (from option in db.options
                    where option.type.Equals(frage.Type) && option.sex.Equals('f')
                    select new OptionModel(option)).ToArray()
                    .OrderBy(model => this.Informal ? model.Name : model.Name.Split(' ')[1]);
            }
        }