コード例 #1
0
        public ActionResult AddProduct(ProductCollectionModel collection)
        {
            try
            {
                // TODO: Add insert logic here
                if (Request.Form.Files.Count > 0)
                {
                    var    file   = Request.Form.Files[0];
                    byte[] buffer = new byte[file.Length];
                    file.OpenReadStream().Read(buffer, 0, (int)file.Length);
                    collection.FileName     = file.FileName;
                    collection.ProductImage = buffer;
                    azureBlobStorage.UploadToBlobAsync(collection);
                }
                else
                {
                    collection.FileName = "NoImage.png";
                }


                productoInventRepository.AddNewProduct(collection);
                sendEmailLogic.SendMail(collection);
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
コード例 #2
0
 public ActionResult AddProduct(ProductCollectionModel collection)
 {
     try
     {
         // TODO: Add insert logic here
         productoInventRepository.AddNewProduct(collection);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }