Beispiel #1
0
 public ActionResult Create(Product product)
 {
     try
     {
         if (ModelState.IsValid)
         {
             productRepository.Insert(product);
             productRepository.Save();
             return RedirectToAction("Index");
         }
         else
         {
             return View();
         }
     }
     catch (Exception)
     {
         return RedirectToAction("ErrorPage","Home");
     }
 }
Beispiel #2
0
 public void Insert(Product product)
 {
     entities.Products.Add(product);
 }
Beispiel #3
0
        // Добавление возможности вводить как точку так и запятую
        // Adding the ability to enter a point or a comma
        protected void ChangeFormCollectionValues(Product obj, FormCollection collection)
        {
            collection["Price"] = collection["Price"].Replace(" ", "");
            collection["Price"] = collection["Price"].Replace(",", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);
            collection["Price"] = collection["Price"].Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);

            collection["PurchasePrice"] = collection["PurchasePrice"].Replace(" ", "");
            collection["PurchasePrice"] = collection["PurchasePrice"].Replace(",", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);
            collection["PurchasePrice"] = collection["PurchasePrice"].Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator);
        }