コード例 #1
0
        public ActionResult CreateSalesSupply(SalesSupplyViewModel salesView)
        {
            if (Session["LoggedContactId"] != null)
            {
                if (ModelState.IsValid)
                {
                    if (int.TryParse(Session["LoggedContactId"].ToString(), out int id))
                    {
                        ContactInfo contact = db.GetContactById(id);

                        // Convert deadline date and time into a DateTime object

                        /*
                         * SalesSupply newSale = new SalesSupply(salesView.MetalType, salesView.MetalAmount, salesView.Deadline, contact);
                         * db.SalesSupplies.Add(newSale);
                         * contact.SalesSupplies.Add(newSale);
                         * db.SaveChanges();
                         */
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View(salesView));
                    }
                }
                else
                {
                    return(View(salesView));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
コード例 #2
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;
        }