public async Task <IActionResult> EnterSheet(List <Bid> bids)
        {
            var id = bids[0]?.DonationId;

            if (ModelState.IsValid)
            {
                foreach (Bid bid in bids)
                {
                    try
                    {
                        if (bid.BidId <= 0)
                        {
                            _context.Add(bid);
                        }
                        else
                        {
                            _context.Update(bid);
                        }

                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!BidExists(bid.BidId))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                ViewBag.Message = "Data Successfully Saved";
                ModelState.Clear();

                bids = _context.Bid.Where(m => m.DonationId == id.Value).ToList();
                if (bids == null || bids.Count < 1)
                {
                    bids = new List <Bid>()
                    {
                        new Bid()
                        {
                            DonationId = id.Value
                        }
                    }
                }
                ;
            }

            if (!id.HasValue)
            {
                return(NotFound());
            }

            ViewBag.DonationId = id.Value;
            ViewBag.Paddles    = _context.Paddle.ToList();

            return(View(bids));
        }
        public async Task <IActionResult> Edit(int id, [Bind("BidderId,MemberOrFriend,PrimaryFirstName,PrimaryLastName,SecondaryFirstName,SecondaryLastName,AddressLine1,AddressLine2,City,State,ZipCode,PhoneNumber,EmailAddress,AmountPaid")] Bidder bidder)
        {
            if (id != bidder.BidderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    bidder.AmountPaid = 0;
                    _context.Update(bidder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BidderExists(bidder.BidderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bidder));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DonationID,DonorID,Title,Description,EstimatedValue,SuggestedStartingBid,UnitsOffered,PotentialTaxBreak,DateOfEvent,RainDate")] Donation donation)
        {
            if (id != donation.DonationID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(donation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DonationExists(donation.DonationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                ViewBag.Donors = new SelectList(_context.Donor.ToList(), "DonorID", "FullID");
                return(View(donation));
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("PaddleId,BidderId,PaddleNumber")] Paddle paddle)
        {
            if (id != paddle.PaddleId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paddle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaddleExists(paddle.PaddleId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                ViewBag.Bidders = new SelectList(_context.Bidder.ToList(), "BidderId", "FullName");
                return(View(paddle));
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("DonorID,FirstName,LastName,PhoneNumber,EmailAddress,RepeatDonor")] Donor donor)
        {
            if (id != donor.DonorID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(donor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DonorExists(donor.DonorID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(donor));
        }