public void Add(MainModel mainModel)
 {
     try
     {
         if (mainModel == null)
         {
             return;
         }
         using (var db = new SnowQueen())
         {
             var order = new Orders
             {
                 priceOfProduct = Convert.ToDecimal(mainModel.Price),
                 countOfProduct = mainModel.Count,
                 id_product     = GetProductId(mainModel.Name)
             };
             db.Orders.Add(order);
             db.SaveChanges();
         }
     }
     catch
     {
         //ignored
     }
 }
 private static int GetProductId(string productName)
 {
     using (var db = new SnowQueen())
     {
         if (db.Products.SingleOrDefault(x => x.productName == productName) == null)
         {
             var newProduct = new Products
             {
                 productName = productName
             };
             db.Products.Add(newProduct);
             db.SaveChanges();
         }
         return(db.Products.Single(x => x.productName == productName).id);
     }
 }