public async Task <IActionResult> Edit(int id, [Bind("brand,toolbox,hasToolbox,ID,name,price,SKU,acqDate")] Tool tool)
        {
            if (id != tool.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tool);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ToolExists(tool.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tool));
        }
Esempio n. 2
0
        public async Task CompleteRentalAsync(Guid rentalId, CancellationToken cancellationToken = default)
        {
            if (rentalId == Guid.Empty)
            {
                throw new ArgumentNullException();
            }

            var rental = await GetAsync(rentalId);

            if (rental == null)
            {
                throw new ArgumentNullException();
            }

            rental.RentalReturnTime = DateTime.UtcNow;
            rental.HasBeenReturned  = true;

            toolShedContext.Update(rental);
            await toolShedContext.SaveChangesAsync(cancellationToken);
        }