Exemple #1
0
        public async Task <IActionResult> Create([Bind("Name,Description,QuantityOnHand,BackorderFlag")] Product product)
        {
            try
            {
                if (await this.DoesNameExists(product))
                {
                    ModelState.AddModelError("error_msg", "This name already exists. Please use a different name.");
                    return(View(product));
                }
                else
                {
                    await _repo.AddObject <Product>(product);

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error occured in Product:Create", null);
                throw;
            }
        }