public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,Price,ImagePath")] FlowerProduct flowerProduct)
        {
            if (id != flowerProduct.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    flowerProduct.DateLastModified = DateTime.Now;
                    _context.Update(flowerProduct);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FlowerProductExists(flowerProduct.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(flowerProduct));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Description,Price,ImagePath")] FlowerProduct flowerProduct)
        {
            if (ModelState.IsValid)
            {
                flowerProduct.DateCreated      = DateTime.Now;
                flowerProduct.DateLastModified = DateTime.Now;
                _context.Add(flowerProduct);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(flowerProduct));
        }
Пример #3
0
        public async Task <IActionResult> Details(int?id)
        {
            FlowerProduct model = await _context.FlowerProducts.FindAsync(id);

            return(View(model));
        }