Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CustomerName,Phonenumber,Email,Age")] 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,Bike_Name,Model,Make,Year")] Bike bike)
        {
            if (id != bike.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bike);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BikeExists(bike.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bike));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Address,Date_of_Birth")] Staff staff)
        {
            if (id != staff.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staff);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffExists(staff.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CustomerId,StaffId,BikeId")] Buy buy)
        {
            if (id != buy.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(buy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BuyExists(buy.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BikeId"]     = new SelectList(_context.Bike, "Id", "Id", buy.BikeId);
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "Id", "Id", buy.CustomerId);
            ViewData["StaffId"]    = new SelectList(_context.Set <Staff>(), "Id", "Id", buy.StaffId);
            return(View(buy));
        }