Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] 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)));
            }
            return(View(store));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info,CountryId")] Brand brand)
        {
            if (id != brand.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(brand);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BrandExists(brand.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Name", brand.CountryId);
            return(View(brand));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price,Year,Info,BrandId")] Bicycle bicycle)
        {
            if (id != bicycle.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bicycle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BicycleExists(bicycle.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"] = new SelectList(_context.Brands, "Id", "Name", bicycle.BrandId);
            return(View(bicycle));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BicycleId,StoreId")] Sale sale)
        {
            if (id != sale.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sale);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaleExists(sale.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BicycleId"] = new SelectList(_context.Bicycles, "Id", "Name", sale.BicycleId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "Id", "Name", sale.StoreId);
            return(View(sale));
        }