Esempio n. 1
0
        public MainWindow()
        {
            //InitializeComponent();
            DataBaseEntities db     = new DataBaseEntities();
            StreamReader     reader = new StreamReader("C:\\Users\\Mikhail\\Desktop\\DigitalSkills2017-авиакомпания\\Сессия 1\\UserData.csv");

            while (!reader.EndOfStream)
            {
                User user = new User();
                var  data = reader.ReadLine().Split(',');
                //user.RoleID = db.Roles.FirstOrDefault(i => i.Title == data[0]).ID;
                user.Email     = data[1];
                user.Password  = GetHash(data[2]);
                user.FirstName = data[3];
                user.LastName  = data[4];
                user.OfficeID  = db.Offices.FirstOrDefault(i => i.Title == data[5]).ID;
                db.Users.Add(user);
            }
            db.SaveChangesAsync();
        }