public static KeyValuePair <DictGroup, IEnumerable <DictValue> > CreateDictGroup(this DAL <MainDbContext> dal, DictGroup dictGroup, IEnumerable <DictValue> values) { var newDictGroup = dal.Create <DictGroup>(dictGroup); foreach (var value in values) { value.DictGroup = newDictGroup; dal.Create(value); } return(new KeyValuePair <DictGroup, IEnumerable <DictValue> >(newDictGroup, values)); }
private void addDefaultDictAttribTypes(MainDbContext context) { var dal = new DAL <MainDbContext>(context); #region sex var sexGroup = new DictGroup { Code = "SEX", Description = "Пол" }; var sexValues = new List <DictValue>() { dal.Create <DictValue>(new DictValue { Code = "MALE", Description = "Мужской", }), dal.Create <DictValue>(new DictValue { Code = "FEMALE", Description = "Женский", }), }; sexGroup = dal.CreateDictGroup(sexGroup, sexValues).Key; dal.Create <AttribType>(new AttribType { DictGroup = sexGroup, Type = typeof(DictGroup).FullName, }); #endregion #region cost var costGroup = new DictGroup { Code = "COST", Description = "Цена" }; var costs = new int[] { 150, 170, 180, 200, 220, 240, 250, 270, 280, 300, 350, 400, 450, 500, 550, 600, 650, 700, 800, 900, 1000, 1500, 2000, 3000, 4000, 5000 }; var costValues = costs.ToList().Select(x => dal.Create <DictValue>(new DictValue { Code = "COST_" + x.ToString(), Description = x.ToString(), })); costGroup = dal.CreateDictGroup(costGroup, costValues).Key; dal.Create <AttribType>(new AttribType { DictGroup = costGroup, Type = typeof(DictGroup).FullName, }); #endregion #region education var educationGroup = new DictGroup { Code = "EDUCATION", Description = "Образование" }; var educationValues = new List <DictValue>() { dal.Create <DictValue>(new DictValue { Code = "MIDDLE", Description = "Среднее", }), dal.Create <DictValue>(new DictValue { Code = "MIDDLE_FULL", Description = "Среднее полное", }), dal.Create <DictValue>(new DictValue { Code = "INCOMPLETE_HEIGHT", Description = "Неоконченное высшее", }), dal.Create <DictValue>(new DictValue { Code = "HEIGHT", Description = "Высшее", }), }; educationGroup = dal.CreateDictGroup(educationGroup, educationValues).Key; dal.Create <AttribType>(new AttribType { DictGroup = educationGroup, Type = typeof(DictGroup).FullName, }); #endregion #region desired work var workGroup = new DictGroup { Code = "JOB", Description = "Желаеммая работа" }; var workValues = new List <DictValue>() { dal.Create <DictValue>(new DictValue { Code = "MERC", Description = "Мерчендайзер", }), dal.Create <DictValue>(new DictValue { Code = "SUPER", Description = "Супервайзер", }), dal.Create <DictValue>(new DictValue { Code = "COURIER", Description = "Курьер", }), dal.Create <DictValue>(new DictValue { Code = "AUDITOR", Description = "Аудитор/Чекер", }), dal.Create <DictValue>(new DictValue { Code = "BUYER", Description = "Тайный покупатель", }), dal.Create <DictValue>(new DictValue { Code = "PROMOUTER", Description = "Промоутер", }), dal.Create <DictValue>(new DictValue { Code = "AUDITOR", Description = "Аудитор/Чекер", }), dal.Create <DictValue>(new DictValue { Code = "ANIMATOR", Description = "Аниматор", }), dal.Create <DictValue>(new DictValue { Code = "PROMO_MODEL", Description = "Промо-модель", }), dal.Create <DictValue>(new DictValue { Code = "MASCOT", Description = "Ростовая кукла", }), dal.Create <DictValue>(new DictValue { Code = "INTERVIEWER", Description = "Интервьюер", }), dal.Create <DictValue>(new DictValue { Code = "MODEL", Description = "Модель", }), dal.Create <DictValue>(new DictValue { Code = "WORKER", Description = "Разнорабочий", }), dal.Create <DictValue>(new DictValue { Code = "BARMEN", Description = "Бармен", }), dal.Create <DictValue>(new DictValue { Code = "WAITER", Description = "Официант", }), dal.Create <DictValue>(new DictValue { Code = "HOSTESS", Description = "Хостес", }), }; workGroup = dal.CreateDictGroup(workGroup, workValues).Key; dal.Create <AttribType>(new AttribType { DictGroup = workGroup, Type = typeof(DictGroup).FullName, }); #endregion }