示例#1
0
        public void CreateDataRow(string bandit_name, string bandit_nickname, string bandit_birthday, string photo, string bandit_status,
                                  string bandit_religion, string bandit_language, string bandit_profession, string bandit_role, int bandit_rise, int bandit_weight,
                                  string bandit_eyecolor, string bandit_haircolor, string bandit_citizen, string bandit_nationality)
        {
            InterpolContext context = new InterpolContext();

            Person person = new Person
            {
                person_name     = bandit_name,
                person_nickname = bandit_nickname,
                person_birthday = bandit_birthday,
                person_status   = bandit_status,
                photo_path      = photo
            };

            context.Persons.Add(person);
            context.SaveChanges();

            int bandit_id = context.Persons.Where(c => c.person_nickname == bandit_nickname).Select(c => c.person_id).FirstOrDefault();

            Criminal crim = new Criminal
            {
                person_profession = bandit_profession,
                person_role       = bandit_role,
                person_id         = bandit_id
            };

            context.Criminals.Add(crim);
            context.SaveChanges();

            Passport pass = new Passport
            {
                person_citizenship = bandit_citizen,
                person_nationality = bandit_nationality,
                person_id          = bandit_id
            };

            context.Passports.Add(pass);
            context.SaveChanges();

            Spirit sp = new Spirit
            {
                person_language = bandit_language,
                person_religion = bandit_religion,
                person_id       = bandit_id
            };

            context.Spirits.Add(sp);
            context.SaveChanges();

            Parameter par = new Parameter
            {
                person_rise      = bandit_rise,
                person_weight    = bandit_weight,
                person_eyecolor  = bandit_eyecolor,
                person_haircolor = bandit_haircolor,
                person_id        = bandit_id
            };

            context.Parameters.Add(par);
            context.SaveChanges();

            Permit permit = new Permit
            {
                permit_value = "Свободна",
                person_id    = bandit_id
            };

            context.Permits.Add(permit);
            context.SaveChanges();
        }