예제 #1
0
        protected override void Seed(AuctionLibrary.Storage.AuctionDB context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            ContactInfo c1 = new ContactInfo("Kim", "12345678", "*****@*****.**");
            ContactInfo c2 = new ContactInfo("Mathias", "87654321", "*****@*****.**");
            ContactInfo c3 = new ContactInfo("Anne Lisbeth Møller Johansen-Jensen", "24681012", "*****@*****.**");
            ContactInfo c4 = new ContactInfo("Bob Allan Aagaard Abildgaard-Pedersen", "12108642", "*****@*****.**");

            SalesSupply s1 = new SalesSupply(MetalType.Guld, 50, new DateTime(2020, 05, 10, 13, 00, 00), c1);
            SalesSupply s2 = new SalesSupply(MetalType.Sølv, 30, new DateTime(2020, 05, 30, 17, 00, 00), c1);
            SalesSupply s3 = new SalesSupply(MetalType.Platin, 100, new DateTime(2020, 05, 23, 08, 30, 00), c2);
            SalesSupply s4 = new SalesSupply(MetalType.Palladium, 80, new DateTime(2020, 06, 02, 15, 30, 00), c2);
            SalesSupply s5 = new SalesSupply(MetalType.Sølv, 300, new DateTime(2020, 05, 30, 17, 00, 00), c3);
            SalesSupply s6 = new SalesSupply(MetalType.Platin, 150, new DateTime(2020, 05, 23, 08, 30, 00), c3);
            SalesSupply s7 = new SalesSupply(MetalType.Guld, 500, new DateTime(2020, 06, 10, 14, 00, 00), c4);
            SalesSupply s8 = new SalesSupply(MetalType.Sølv, 380, DateTime.Now.AddMinutes(10), c4);

            context.ContactInfoes.AddOrUpdate(c => c.Id, c1);
            context.ContactInfoes.AddOrUpdate(c => c.Id, c2);
            context.ContactInfoes.AddOrUpdate(c => c.Id, c3);
            context.ContactInfoes.AddOrUpdate(c => c.Id, c4);

            context.SalesSupplies.AddOrUpdate(s => s.Id, s1);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s2);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s3);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s4);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s5);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s6);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s7);
            context.SalesSupplies.AddOrUpdate(s => s.Id, s8);
        }
예제 #2
0
        //------------------------------ EVENTHANDLERS --------------------------------------------------------

        /**
         * This eventhandler validates the user
         * as a buyer and returns a new window
         * if the validations checks out.
         * Validation fails if the buyer is the
         * seller of the salesSupply or if the
         * auction for the sales supply has
         * reach deadline. As a bonus if the
         * auction for the sales supply has
         * reached deadline and the buyer
         * has won the action, a dialog will
         * appear to inform the user, if the
         * user cliks on the auction.
         */
        private void AddBuyingOffer_DoubleClick(object sender, RoutedEventArgs e)
        {
            SalesSupply listItem      = ListBox.SelectedItem as SalesSupply;
            SalesSupply salesSupply   = _context.GetSalesSupply(listItem.Id);
            ContactInfo contactSeller = salesSupply.ContactInfo;

            if (contactSeller != null)
            {
                if (contactSeller != _buyerInfo && salesSupply.Deadline > DateTime.Now)
                {
                    BuyingOfferWindow offerWindow = new BuyingOfferWindow(this, salesSupply, _buyerInfo);
                    offerWindow.Show();
                    this.Hide();
                }
                else if (contactSeller == _buyerInfo)
                {
                    MessageBox.Show("Du kan ikke byde på dit eget salgsudbud.", "Fejlmeddelelse", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else if (salesSupply.HighestBuyingOffer != null && salesSupply.HighestBuyingOffer.ContactInfo == _buyerInfo)
                {
                    MessageBox.Show("Tillykke! Du har vundet denne auktion.", "Lykønskning", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("Tidsfristen er udløbet. Auktionen er lukket.", "Information", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }
예제 #3
0
        /**
         * Method to update references, used when a
         * new buyingoffer is placed on a salesSupply.
         */
        public void AddBuyingOfferToSalesSupply(SalesSupply sale, BuyingOffer offer)
        {
            SalesSupply dbSalesSupply = SalesSupplies
                                        .Where(s => s.Id == sale.Id)
                                        .FirstOrDefault();

            dbSalesSupply.HighestBuyingOffer = offer;
            dbSalesSupply.HighestPrice       = offer.PriceAmount;
            offer.SalesSupply = dbSalesSupply;
        }
예제 #4
0
        public BuyingOfferWindow(MainWindow main, SalesSupply salesSupply, ContactInfo buyerInfo)
        {
            InitializeComponent();
            _main        = main;
            _context     = new AuctionDB();
            _salesSupply = _context.GetSalesSupply(salesSupply.Id);
            _buyerInfo   = _context.GetContactById(buyerInfo.Id);
            DataContext  = _salesSupply;

            // Set image.
            MetalImage.DataContext = _salesSupply.ImgPath;

            // Add text to binded labels.
            BindedMetalAmount.Content  = _salesSupply.MetalAmount + " gram";
            BindedPrice.Content        = _salesSupply.HighestPrice + " kr";
            BindedDeadline.DataContext = _salesSupply.DeadlineToString;
        }