Example #1
0
 private void Regisration_Click(object sender, RoutedEventArgs e)
 {
     //TODO: add account to database;
     using (AuctionContext db = new AuctionContext())
     {
         IEnumerable <Account> accounts = from acc in db.Accounts where acc.Login.Equals(RegLogin.Text) select acc;
         if (accounts.Count() != 0)
         {
             MessageBox.Show("Такой аккаунт уже существует", "Ошибка", MessageBoxButton.OK);
         }
         else
         {
             ((Entering)this.Owner).EnterData(RegLogin.Text, FirstPass.Password);
             db.Accounts.Add(new Account(RegLogin.Text, Account.GetHashCode(FirstPass.Password), Email.Text));
             db.SaveChanges();
             this.Close();
         }
     }
 }
Example #2
0
 private void AddProd_Click(object sender, RoutedEventArgs e)
 {
     using (AuctionContext db = new AuctionContext())
     {
         if (!System.IO.File.Exists(ImagePath.Text))
         {
             MessageBox.Show("Файл не найден", "Ошибка", MessageBoxButton.OK);
         }
         else if (Regex.IsMatch(Price.Text, @"[^0-9.,]+") || Regex.IsMatch(Price.Text, @""))
         {
             MessageBox.Show("Цена задана не верно", "Ошибка", MessageBoxButton.OK);
         }
         else
         {
             Product product = new Product(ImagePath.Text, float.Parse(Price.Text, System.Globalization.CultureInfo.InvariantCulture), "Почка Виталия", "Почка здоровая не очень большая, справка прилагается", account.AccountId);
             //db.Products.Add(product);
             //db.SaveChanges();
             //ProductBufferItem pbItem = new ProductBufferItem(((Product)db.Products.Where(n => n.Name.Equals(product.Name)).FirstOrDefault()).ProductID);
             //db.ProductBuffer.Add(pbItem);
             //db.SaveChangesAsync();
         }
     }
 }