public async Task <IActionResult> Create([Bind("ID,RetailerName,Adress")] Retailer retailer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(retailer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(retailer));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Name,ShortDescription,Price")] Pie pie)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(pie);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            } catch (DbUpdateException /* ex*/)
            {
                ModelState.AddModelError("", "Unable to save changes." + "Try again, and if the problem persists ");
            }
            return(View(pie));
        }