public ActionResult CreateNewProduct(ProductModel product)
 {
     if (ModelState.IsValid)
     {
         product.Quantity = 0;
         ProductManager productManager = new ProductManager();
         productManager.AddNewProduct(product);
         ProductModel newProduct = new ProductModel();
         ViewBag.Massege = "Saccess!!!";
         return PartialView("CreateNewProduct", newProduct);
     }
     else
     {
         ModelState.AddModelError("", "Data is not valid");
         return PartialView("CreateNewProduct", product);
     }
 }
        public JsonResult EndEditRow(ProductModel productBeforeEdit)
        {
            JsonResult result;

            result = new JsonResult()
            {
                Data = new { isChanges = LogSystem.Instance.IsСhanged(productBeforeEdit) }
            };
            return result;
        }
 public ActionResult TableChangesProduct(ProductModel[] listProduct)
 {
     TableChangesProduct tableChangesProduct = LogSystem.Instance.GetTableChangesProduct(listProduct[0], listProduct[1]);
     return PartialView("TableChangesProduct", tableChangesProduct);
 }
 public void UpdateProduct(ProductModel product)
 {
     try
     {
         using (var db = GetDbConnection())
         {
             Product updatingProduct = db.Product.FirstOrDefault(it => it.Id == product.Id);
             if (updatingProduct != null)
             {
                 updatingProduct.Name = product.Name;
                 updatingProduct.Price = product.Price;
                 updatingProduct.Quantity = product.Quantity;
                 db.SaveChanges();
             }
         }
     }
     catch (NullReferenceException e)
     {
         LogSystem.Instance.PublishErrorMassage(ErrorDictionary.DB_HAVE_NOT_ITEM);
     }
     catch (System.Data.Entity.Core.ProviderIncompatibleException e)
     {
         LogSystem.Instance.PublishErrorMassage(ErrorDictionary.NON_DB_CONNECTION);
     }
     catch (Exception e)
     {
         LogSystem.Instance.PublishErrorMassage(ErrorDictionary.MASSAGE_UNNOUN_ERROR);
     }
 }
 private ProductModel PreparationModel(ProductModel product)
 {
     product.TotalCost = product.Price * product.Quantity;
     return product;
 }
 public Boolean UpdateProduct(ProductModel product)
 {
     SourseDbFactory.GetSourseDB().UpdateProduct(product);
     return true;
 }
 public void AddNewProduct(ProductModel product)
 {
     SourseDbFactory.GetSourseDB().AddNewProduct(product);
 }