Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,PhoneNumber,Email")] 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("Index"));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(int id, ICollection <IFormFile> files, [Bind("ID,ItemName,Description,Type,GemStones,Image,Date,Length,Weight,Price")] Merchandise merchandise)
        {
            var uploadLoaction = Path.Combine(environment.ContentRootPath, "wwwroot\\images\\Merchandise\\");

            if (id != merchandise.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(merchandise);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MerchandiseExists(merchandise.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(merchandise));
        }