Ejemplo n.º 1
0
        public async Task <IActionResult> Add(Clothing c)
        {
            if (ModelState.IsValid)
            {
                await ClothingDB.Add(c, _context);

                // TempData lasts for one redirect
                TempData["Message"] = $"{c.Title} added successfully";
                return(RedirectToAction("ShowAll"));
            }
            //Return same view with error messages
            return(View(c));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Add(Clothing c) // Asynchronous Method
        {
            if (ModelState.IsValid)
            {
                await ClothingDB.Add(c, _context);

                // TempData lasts for one redirect, stays in memory
                TempData["Message"] = $"{c.Title} Added Successfully";
                return(RedirectToAction("ShowAll"));
            }

            // return same view with validation error messages
            return(View(c));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Add(Clothing c)
        {
            if (ModelState.IsValid)
            {
                await ClothingDB.Add(c, _context);

                // Temp data lasts for one redirect
                TempData["Message"] = $"{c.Title} added successfully";
                return(RedirectToAction(nameof(InventoryList)));
            }
            else
            {
                //Return same view with validation messages
                return(View(c));
            }
        }