//------------------------------ EVENTHANDLERS --------------------------------------------------------

        /**
         * This method assigns the best BuyingOffer
         * of a salesSupply to a new value object,
         * overwriting the existing value.
         */
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            string priceStr = TxtBoxPriceOffer.Text;
            double oldOffer = _salesSupply.HighestPrice;

            if (priceStr == null || priceStr == "" || priceStr == "Angiv pris")
            {
                ErrorLabel.Content    = "Indtast venligst et beløb.";
                ErrorLabel.Visibility = Visibility.Visible;
            }
            else
            {
                try
                {
                    double price = Convert.ToDouble(priceStr);

                    if (price > oldOffer && !priceStr.Contains("-"))
                    {
                        BuyingOffer offer = new BuyingOffer(price, _salesSupply, _buyerInfo);
                        _context.AddBuyingOfferToSalesSupply(_salesSupply, offer);
                        _context.SaveChanges();

                        _main.ListBox.ItemsSource = null;
                        _main.ListBox.ItemsSource = _context.GetSalesSupplies();
                        _main.Show();
                        this.Hide();
                    }
                    else if (priceStr.Contains("-"))
                    {
                        ErrorLabel.Content    = "Indtast venligst et positivt tal.";
                        ErrorLabel.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        ErrorLabel.Content    = "Indtast venligst et beløb som overgår det forrige bud.";
                        ErrorLabel.Visibility = Visibility.Visible;
                    }
                }
                catch (Exception)
                {
                    ErrorLabel.Content    = "Indtast venligst et tal.";
                    ErrorLabel.Visibility = Visibility.Visible;
                }
            }
        }
Exemple #2
0
 // GET: Front page
 public ActionResult Index()
 {
     if (Session["LoggedContactId"] != null)
     {
         return(View(new SalesSupplyViewModel()
         {
             SalesSupplies = db.GetSalesSupplies()
         }));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
Exemple #3
0
        public MainWindow(string name, string number, string email)
        {
            InitializeComponent();
            _name       = name;
            _number     = number;
            _email      = email;
            _context    = new AuctionDB();
            DataContext = _context;

            ContactInfo dbBuyerInfo = _context.GetContactInfoByStrings(_name, _number, _email);

            if (dbBuyerInfo == null)
            {
                _buyerInfo = new ContactInfo(_name, _number, _email);
                _context.ContactInfoes.Add(_buyerInfo);
                _context.SaveChanges();
            }
            else
            {
                _buyerInfo = dbBuyerInfo;
            }

            ListBox.ItemsSource = _context.GetSalesSupplies();
        }