Ejemplo n.º 1
0
        private void CreateUser()
        {
            var address = new Address
            {
                City         = textBoxOras.Text,
                Street       = textBoxStrada.Text,
                StreetNumber = textBoxNr.Text,
                CodPostal    = textBoxCode.Text,
            };

            dBUserContext.Addresses.Add(address);

            var user = new User
            {
                AddressId  = address.Id,
                UserTypeId = (comboBoxTip.SelectedItem as UserType).Id,
                Nume       = textBoxNume.Text,
                Prenume    = textBoxPrenume.Text,
                UserName   = textBoxUserName.Text,
                Parola     = textBoxParola.Text
            };

            dBUserContext.Users.Add(user);
            dBUserContext.SaveChanges();
        }
Ejemplo n.º 2
0
        private void CreateBook()
        {
            var author = new Author
            {
                Nume    = textBoxNumeA.Text,
                Prenume = textBoxPrenumeA.Text,
            };

            dBUserContext.Authors.AddOrUpdate(author);

            var book = new Book
            {
                AuthorId = author.Id,
                Title    = textBoxTitlu.Text,
                Year     = int.Parse(textBoxAn.Text),
                Price    = decimal.Parse(textBoxPret.Text)
            };

            dBUserContext.Books.Add(book);
            dBUserContext.SaveChanges();
        }