Example #1
0
        public IActionResult Delete(int ItemId)
        {
            List <Bid> BadBids = _context.Bid.Where(Item => Item.ItemId == ItemId).ToList();

            _context.Remove(BadBids);
            _context.SaveChanges();
            var BadItem = _context.Item.SingleOrDefault(Item => Item.ItemId == ItemId);

            _context.Remove(BadItem);
            _context.SaveChanges();
            return(RedirectToAction("Auction"));
        }
Example #2
0
        public IActionResult DeleteAuction(int id)
        {
            var auction = dbContext.Auctions.FirstOrDefault(w => w.AuctionId == id);

            dbContext.Remove(auction);
            dbContext.SaveChanges();
            return(RedirectToAction("Dashboard"));
        }
Example #3
0
        // This handles the add auction logic
        private dynamic delete_auction(int id)
        {
            // Get the auction from the table
            Auction auction = _context.Auctions.Where(x => x.Id == id).SingleOrDefault();

            // Remove the auction
            _context.Remove(auction);
            _context.SaveChanges();
            // Redireect to Index
            return(RedirectToAction("Index"));
        }
Example #4
0
        public IActionResult Delete(int id)
        {
            Auction target = _context.Auctions.SingleOrDefault(a => a.id == id);

            if (target == null)
            {
                return(RedirectToAction("Main"));
            }
            if (target.creator_id != HttpContext.Session.GetInt32("id"))
            {
                return(RedirectToAction("Main"));
            }
            if (target.top_bidder_id != 0)
            {
                User topBidder = _context.Users.SingleOrDefault(u => u.id == target.top_bidder_id);
                topBidder.wallet += target.top_bid;
                _context.Update(topBidder);
            }
            _context.Remove(target);
            _context.SaveChanges();
            return(RedirectToAction("Main"));
        }
 public IActionResult Delete(int id)
 {
     _context.Remove(_context.products.SingleOrDefault(c => c.productid == id));
     _context.SaveChanges();
     return(RedirectToAction("Dashboard"));
 }