Esempio n. 1
0
 public ActionResult AddNewType(ProductType productType)
 {
     if (Session["uname"] != null)
     {
         List <ProductType> TypeList = productTypeService.GetAllTypeForCheck(productType);
         if (TypeList.Count == 0)
         {
             if (productType.Name.Length < 3)
             {
                 TempData["LengthError"] = "Product Name Should Contain Atleast 3 Characters";
                 return(RedirectToAction("AddNewType", "Product"));
             }
             else
             {
                 productType.Id = productType.Name[0].ToString() + productType.Name[1].ToString() + productType.Name[2].ToString() + "-" + productType.ShipmentCost;
                 int i = this.productTypeService.Insert(productType);
                 if (i != 0)
                 {
                     @TempData["TypeText"] = "Successfully Added";
                 }
                 return(RedirectToAction("AllTypes", "Product"));
             }
         }
         else
         {
             TempData["LengthError"] = productType.Name + " Product Type is Already Assigned";
             return(RedirectToAction("AddNewType", "Product"));
         }
     }
     return(RedirectToAction("Index", "Home"));
 }