Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CarBrandName,CarModel,CarYear,Fuel,Transmission,Color,InStock,SupplierFK")] Car car)
        {
            if (id != car.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(car);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarExists(car.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SupplierFK"] = new SelectList(_context.Supplier, "Id", "SupplierName", car.SupplierFK);
            return(View(car));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SupplierName,Email,Phone")] Supplier supplier)
        {
            if (id != supplier.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplier);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierExists(supplier.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DateOfPurchase,WarrantyDuration,CarFK,CustomerFK")] Store store)
        {
            if (id != store.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(store);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StoreExists(store.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarFK"]      = new SelectList(_context.Car, "Id", "CarBrandName", store.CarFK);
            ViewData["CustomerFK"] = new SelectList(_context.Customer, "Id", "FullName", store.CustomerFK);
            return(View(store));
        }