public async Task <IActionResult> Edit(int id, [Bind("Id,Number_of_Tickets,Ticket_Price,CustomerId,AttractionId")] Booking booking)
        {
            if (id != booking.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(booking);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookingExists(booking.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AttractionId"] = new SelectList(_context.Attraction, "Id", "Address", booking.AttractionId);
            ViewData["CustomerId"]   = new SelectList(_context.Customer, "Id", "Id", booking.CustomerId);
            return(View(booking));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Author,Price,Rating")] Books books)
        {
            if (id != books.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(books);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BooksExists(books.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(books));
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Mobile,Email,Address")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,CustomerID,BooksID,OrderDate")] Order order)
        {
            if (id != order.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BooksID"]    = new SelectList(_context.Books, "ID", "ID", order.BooksID);
            ViewData["CustomerID"] = new SelectList(_context.Customer, "ID", "ID", order.CustomerID);
            return(View(order));
        }
Beispiel #5
0
        public async Task <IActionResult> UpdateCustomerAsync(long id, [FromBody, Required] CustomerInput customer)
        {
            if (context.Customers.Any(c => c.Id == id))
            {
                var updatedCustomer = new Customer(customer)
                {
                    Id = id
                };
                try
                {
                    context.Update(updatedCustomer);
                    await context.SaveChangesAsync();
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(NotFound());
            }

            return(Ok());
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Place,Address,Description,Open_Hours")] Attraction attraction)
        {
            if (id != attraction.Id)
            {
                return(NotFound());
            }

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