protected void btnInsert_Click(object sender, EventArgs e)
        {
            bool        passRequirements = true;
            String      producttypename  = txtProductTypeName.Text;
            ProductType pt = ProductTypeRepository.FindProductTypeByName(producttypename);

            if (txtProductTypeName.Text == "" || producttypename.Length < 5 || pt != null)
            {
                passRequirements = false;
                warningProductTypeName.Visible = true;
            }
            if (txtDescription.Text == "")
            {
                passRequirements           = false;
                warningDescription.Visible = true;
            }
            if (passRequirements == true)
            {
                String description = txtDescription.Text;

                ProductType newProductType = ProductTypeFactory.CreateProductType(producttypename, description);
                ProductTypeRepository.Create(newProductType);

                Response.Redirect("Home.aspx");
            }
        }
Пример #2
0
        public IActionResult Create(ProductTypeDTO model)
        {
            var result = _productTypeRepository.Create(model);

            TempData.AddResult(result);
            if (model.ParentId.HasValue)
            {
                return(RedirectToAction(nameof(SubGroup), new { model.ParentId }));
            }
            return(RedirectToAction(nameof(Index)));
        }