public int SaveProduct(Product product)
 {
     product.ModifedDate = DateTime.Now;
     if (product.ProductCategoryId != default(int))
         product.ProductCategory = _context.ProductCategories.Find(product.ProductCategoryId);
     if (product.ProductId == default(int))
         _context.CreateRecord(product);
     else
         _context.EditRecord(product);
     return product.ProductId;
 }
 public ActionResult Create(Product product, HttpPostedFileBase image = null)
 {
     if (image != null)
     {
         product.ThumbNailPhotoName = image.ContentType;
         product.ThumbNailPhoto = new byte[image.ContentLength];
         image.InputStream.Read(product.ThumbNailPhoto, 0,
         image.ContentLength);
     }
     _repository.SaveProduct(product);
     return RedirectToAction("List");
 }