public static byte[] ResizeAndCompressImage(byte[] imageFileBytes,
                                                    bool isResize,
                                                    int maxWidthPx,
                                                    int maxHeightPx,
                                                    bool isCompress)
        {
            var newImageFileBytes = imageFileBytes;

            if (isResize)
            {
                newImageFileBytes = ImageResizeHelper.Resize(imageFileBytes, maxWidthPx, maxHeightPx);
            }

            if (!isCompress)
            {
                return(newImageFileBytes);
            }

            using var streamToCompress = new MemoryStream(newImageFileBytes);

            var compressResult = ImageCompressor.Compress(streamToCompress);

            newImageFileBytes = compressResult.ResultFileStream.ToArray();

            return(newImageFileBytes);
        }
        public ActionResult Create(Item item, HttpPostedFileBase Filename)
        {
            try
            {
                var files    = Request.Files;
                var ext      = Path.GetExtension(Filename.FileName);
                var filename = Path.GetFileNameWithoutExtension(Filename.FileName);

                if (Filename != null)
                {
                    byte[] imgBinary = ImageResizeHelper.ProcessResizeImage(Filename.InputStream);
                    //item.Image = new System.Data.Linq.Binary(imgBinary);
                    var base64image = Convert.ToBase64String(imgBinary);
                    item.Filename    = filename;
                    item.ImageBase64 = base64image;
                }

                data.SaveItem(item);

                return(RedirectToAction("Index", "Item"));
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError(string.Empty, ex.Message);
                ViewBag.Exception = ex.Message;
            }

            return(View());
        }
Beispiel #3
0
        public ImageMediaContent(string filePath) : base(filePath)
        {
            //Get image
            //this.text = filePath;

            this.fullImage = Xamarin.Forms.ImageSource.FromFile(filePath);

            string fileName          = Path.GetFileNameWithoutExtension(filePath);
            string thumbnailFilePath = Path.Combine(FilePaths.allImageThumbnailsPath, fileName + ".jpg");

            // ISSUE TODO image resize file saving not working on IOS

            this.image = fullImage;

            if (!File.Exists(thumbnailFilePath))
            {
                Task.Run(async() =>
                {
                    await ImageResizeHelper.createImageThumbnailAsync(filePath);
                    this.image = Xamarin.Forms.ImageSource.FromFile(thumbnailFilePath);
                });
            }
            else
            {
                this.image = Xamarin.Forms.ImageSource.FromFile(
                    thumbnailFilePath);
            }
        }
        public ActionResult Edit(int id, Item item)
        {
            try
            {
                var files    = Request.Files;
                var file     = files[0];
                var ext      = Path.GetExtension(file.FileName);
                var filename = Path.GetFileNameWithoutExtension(file.FileName);

                if (file != null && file.ContentLength > 0)
                {
                    byte[] imgBinary = ImageResizeHelper.ProcessResizeImage(file.InputStream);
                    //item.Image = new System.Data.Linq.Binary(imgBinary);
                    var base64image = Convert.ToBase64String(imgBinary);
                    item.Filename    = filename;
                    item.ImageBase64 = base64image;
                }
                else
                {
                    item.Filename = string.Empty;
                }


                data.UpdateItem(item, id);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
        private void OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            TextPointer textPointer = GetPositionFromPoint(e.GetPosition(this), false);

            // image BlockUIContainer
            if (textPointer != null && textPointer.Parent is BlockUIContainer)
            {
                UIElement uiElement = (textPointer.Parent as BlockUIContainer).Child;
                if (uiElement == null)
                {
                    return;
                }

                if (uiElement is Image)
                {
                    ImageResizeHelper.UpdateImageResizers(uiElement as Image);

                    // update the flowdocument when the image is resized
                    ImageResizeHelper.ImageResized += () => SetValue(BoundFlowDocumentProperty, Document);
                    //e.Handled = true;
                    return;
                }
            }

            ImageResizeHelper.ClearImageResizers();
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            //string imageBasePath = @"C:\Users\vd2\Source\Repos\negoshoe-inventory\NegoshoeInventory\ImagesUpload";
            string imageBasePath = @"C:\Users\Valiant\Desktop\Item Pictures";
            //string filePath = "Upload_Template_N.xlsx";
            string     filePath = "test1.xlsx";
            FileStream stream   = File.Open(filePath, FileMode.Open, FileAccess.Read);

            //IExcelDataReader reader = ExcelReaderFactory.CreateBinaryReader(stream);
            IExcelDataReader reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

            reader.IsFirstRowAsColumnNames = true;
            int ctr = 0;

            while (reader.Read())
            {
                if (ctr == 0)
                {
                    ctr++; reader.Read();
                }
                string itemName    = reader.GetString(0);
                string description = reader.GetString(1);
                string brand       = reader.GetString(2);
                string type        = reader.GetString(3);

                string totalQuantity  = reader.GetString(4);
                string officeQuantity = reader.GetString(5);
                string houseQuantity  = reader.GetString(6);
                string filename       = reader.GetString(7);
                string remarks        = reader.GetString(8);
                byte[] imgBinary      = ImageResizeHelper.ProcessResizeImage(Path.Combine(imageBasePath, filename));
                var    base64image    = Convert.ToBase64String(imgBinary);
                //string imageBase64 = reader.GetString(6);

                string sql =
                    "INSERT INTO Items([ItemName],[Brand],[ProductType],[Description],[TotalQuantity],[OfficeQuantity],[HouseQuantity],[Filename],[ImageBase64],[Remarks]) " +
                    "VALUES('" + itemName + "'," + brand + "," + type + ",'" + description + "'," + totalQuantity + "," + officeQuantity + "," + houseQuantity + ",'" + filename + "','" + base64image + "','" + remarks + "');";

                File.AppendAllText("output.sql", sql);

                ctr++;
            }

            reader.Close();
        }
        public string Upload(HttpPostedFileBase File, string w_pacode)
        {
            if (File != null && File.ContentLength > 0)
            {
                string   filename = " ";
                decimal  filesize = 1000048;
                string[] arr      = new string[3] {
                    "jpg", "gif", "png"
                };


                filename = File.FileName;
                int Position = filename.LastIndexOf(".");
                filename = filename.Substring(Position + 1);

                if (File.ContentLength > filesize)
                {
                    return("");
                }
                else if (!arr.Contains(filename.ToLower()))
                {
                    return("");
                }
                else
                {
                    filename = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid() + "_" + w_pacode + "." + filename;
                    string targetfolder = Server.MapPath(ConfigurationManager.AppSettings["StoryPicPath"] + filename);
                    Bitmap origImage    = new Bitmap(File.InputStream);
                    Image  img          = (Image)origImage;
                    img = ImageResizeHelper.ImageResize(origImage, 680, 383, false, false);
                    Bitmap newImage = new Bitmap(img);
                    //File = ImageResizeHelper.ImageResize(File, 183, 136, false, false);
                    newImage.Save(targetfolder);
                    //File.SaveAs(targetfolder);
                    return(filename);
                }
            }
            else
            {
                return("");
            }
        }
Beispiel #8
0
        /// <summary>
        /// Creates a PNGIcoImage from a PNG file
        /// </summary>
        /// <param name="path">The path to a PNG file</param>
        public static PNGIcoImage FromFile(string path)
        {
            var srcBmp   = System.Drawing.Image.FromFile(path);
            var bmp      = ImageResizeHelper.ToNearestAllowed(srcBmp);
            var tempPath = Path.GetTempFileName();

            var w = bmp.Width;
            var h = bmp.Height;

            bmp.Save(tempPath, ImageFormat.Png);
            bmp.Dispose();

            bmp.Dispose();
            return(new PNGIcoImage()
            {
                width = getWidthHeight(w),
                height = getWidthHeight(h),
                data = File.ReadAllBytes(tempPath)
            });
        }
        public ActionResult Upload(HttpPostedFileBase File, string STARS_ID, string w_pacode)
        {
            if (File != null && File.ContentLength > 0)
            {
                string   filename = " ";
                decimal  filesize = 1000048;
                string[] arr      = new string[3] {
                    "jpg", "gif", "png"
                };


                filename = File.FileName;
                int Position = filename.LastIndexOf(".");
                filename = filename.Substring(Position + 1);

                if (File.ContentLength > filesize)
                {
                }
                else if (!arr.Contains(filename.ToLower()))
                {
                }
                else
                {
                    ProfileBL profile = new ProfileBL();
                    filename = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid() + "_" + w_pacode + "." + filename;
                    string targetfolder = Server.MapPath(ConfigurationManager.AppSettings["UploadPath"] + filename);
                    Bitmap origImage    = new Bitmap(File.InputStream);
                    Image  img          = (Image)origImage;
                    img = ImageResizeHelper.ImageResize(origImage, 200, 200, false, false);
                    Bitmap newImage = new Bitmap(img);
                    //File = ImageResizeHelper.ImageResize(File, 183, 136, false, false);
                    newImage.Save(targetfolder);
                    //File.SaveAs(targetfolder);
                    profile.SaveProfilUploadImage(filename, STARS_ID);
                }
            }
            return(RedirectToAction("LBCProfile", "BrandChampion"));
        }
Beispiel #10
0
        public NoteEditor()
        {
            // event handlers
            TextChanged      += OnTextChanged;
            PreviewKeyDown   += OnPreviewKeyDown;
            PreviewMouseDown += OnPreviewMouseDown; // PreviewMouseDown for image resize adorner

            // Credit: http://social.msdn.microsoft.com/Forums/vstudio/en-US/0d672c70-d49d-4ebf-871d-420cc164f7d8/c-wpf-richtextbox-remove-formatting-and-line-spaces
            DataObject.AddPastingHandler(this, DataObjectPastingEventHandler);

            // add custom binding for Ctrl+Shift+V for rich format pasting
            InputBindings.Add(new KeyBinding(ApplicationCommands.Paste, Key.V, ModifierKeys.Control | ModifierKeys.Shift));

            // search results highlight support
            NoteEditorSearchHighlight.Init(this);

            // image resize support
            ImageResizeHelper.Init(this);

            // register global commands
            CommandManager.RegisterClassCommandBinding(typeof(Window), new CommandBinding(FontStylesCommand, OnFontStylesCommand, CanExecuteFontStylesCommand));
            CommandManager.RegisterClassCommandBinding(typeof(Window), new CommandBinding(ParagraphStylesCommand, OnParagraphStylesCommand, CanExecuteParagraphStylesCommand));
        }
Beispiel #11
0
        public async Task <IActionResult> Edit(int id, [Bind("BlogId,BlogTitle,BlogDate,BlogEndDate,BlogDetail,BlogPicTitle,BlogCatId,BlogStatus,BlogCreateDate,BlogCreateBy")] Blog blog, List <IFormFile> files, IFormFile uploadPic, string picold, List <IFormFile> filesUpload, string Startdate, string EndDate)
        {
            /*Check Session */
            var page            = "3";
            var typeofuser      = "";
            var PermisionAction = "";

            // CheckSession
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username")))
            {
                Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                typeofuser      = HttpContext.Session.GetString("TypeOfUserId");
                PermisionAction = HttpContext.Session.GetString("PermisionAction");
                if (PermisionHelper.CheckPermision(typeofuser, PermisionAction, page) == false)
                {
                    Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            /*Check Session */

            var date1  = Startdate.Substring(6, 4) + "-" + Startdate.Substring(3, 2) + "-" + Startdate.Substring(0, 2) + " 00:00:00";
            var date2  = EndDate.Substring(6, 4) + "-" + EndDate.Substring(3, 2) + "-" + EndDate.Substring(0, 2) + " 23:59:59";
            var sdate1 = Startdate;
            var sdate2 = EndDate;
            var rdate1 = Startdate;
            var rdate2 = EndDate;

            if (id != blog.BlogId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    blog.BlogUpdateBy   = HttpContext.Session.GetString("Username");
                    blog.BlogUpdateDate = DateTime.Now;
                    var check = 0;
                    if (uploadPic == null || uploadPic.Length == 0)
                    {
                        blog.BlogPicTitle = picold;
                        check             = 1;
                    }
                    if (check == 0)
                    {
                        if (uploadPic.ContentType.IndexOf("image", StringComparison.OrdinalIgnoreCase) < 0)
                        {
                            blog.BlogPicTitle = picold;
                            check             = 1;
                        }
                    }
                    if (check == 0)
                    {
                        string pathImage = "/images/BlogTitle/";
                        string pathSave  = $"wwwroot{pathImage}";
                        if (!Directory.Exists(pathSave))
                        {
                            Directory.CreateDirectory(pathSave);
                        }
                        if (!Directory.Exists(pathSave + "/32/"))
                        {
                            Directory.CreateDirectory(pathSave + "/32/");
                        }
                        if (!Directory.Exists(pathSave + "/64/"))
                        {
                            Directory.CreateDirectory(pathSave + "/64/");
                        }
                        if (!Directory.Exists(pathSave + "/128/"))
                        {
                            Directory.CreateDirectory(pathSave + "/128/");
                        }
                        if (!Directory.Exists(pathSave + "/256/"))
                        {
                            Directory.CreateDirectory(pathSave + "/256/");
                        }
                        if (!Directory.Exists(pathSave + "/512/"))
                        {
                            Directory.CreateDirectory(pathSave + "/512/");
                        }
                        if (!Directory.Exists(pathSave + "/1028/"))
                        {
                            Directory.CreateDirectory(pathSave + "/1028/");
                        }

                        string fileName  = Path.GetFileNameWithoutExtension(uploadPic.FileName);
                        string extension = Path.GetExtension(uploadPic.FileName);
                        fileName = fileName + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + extension;
                        var path = Path.Combine(Directory.GetCurrentDirectory(), pathSave, fileName);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await uploadPic.CopyToAsync(stream);
                        }
                        ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/32/" + fileName, 32);
                        ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/64/" + fileName, 64);
                        ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/128/" + fileName, 128);
                        ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/256/" + fileName, 256);
                        ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/512/" + fileName, 512);
                        ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/1028/" + fileName, 1028);

                        blog.BlogPicTitle = fileName;
                    }

                    blog.BlogDate    = Convert.ToDateTime(date1);
                    blog.BlogEndDate = Convert.ToDateTime(date2);
                    _context.Update(blog);
                    await _context.SaveChangesAsync();

                    var IDBLOG = blog.BlogId;

                    if (files != null && files.Count > 0)
                    {
                        //Upload file
                        string pathImage = "/images/Board/";
                        string pathSave  = $"wwwroot{pathImage}";
                        if (!Directory.Exists(pathSave))
                        {
                            Directory.CreateDirectory(pathSave);
                        }
                        if (!Directory.Exists(pathSave + "/32/"))
                        {
                            Directory.CreateDirectory(pathSave + "/32/");
                        }
                        if (!Directory.Exists(pathSave + "/64/"))
                        {
                            Directory.CreateDirectory(pathSave + "/64/");
                        }
                        if (!Directory.Exists(pathSave + "/128/"))
                        {
                            Directory.CreateDirectory(pathSave + "/128/");
                        }
                        if (!Directory.Exists(pathSave + "/256/"))
                        {
                            Directory.CreateDirectory(pathSave + "/256/");
                        }
                        if (!Directory.Exists(pathSave + "/512/"))
                        {
                            Directory.CreateDirectory(pathSave + "/512/");
                        }
                        if (!Directory.Exists(pathSave + "/1028/"))
                        {
                            Directory.CreateDirectory(pathSave + "/1028/");
                        }

                        foreach (IFormFile item in files)
                        {
                            if (item.Length > 0)
                            {
                                string fileName  = Path.GetFileNameWithoutExtension(item.FileName);
                                string extension = Path.GetExtension(item.FileName);
                                fileName = fileName + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + extension;
                                var path = Path.Combine(Directory.GetCurrentDirectory(), pathSave, fileName);
                                using (var stream = new FileStream(path, FileMode.Create))
                                {
                                    await item.CopyToAsync(stream);
                                }
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/32/" + fileName, 32);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/64/" + fileName, 64);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/128/" + fileName, 128);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/256/" + fileName, 256);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/512/" + fileName, 512);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/1028/" + fileName, 1028);
                                var blogPic = new BlogPic {
                                    BlogPicName = fileName, BlogId = IDBLOG
                                };
                                _context.BlogPics.Add(blogPic);
                                _context.SaveChanges();
                            }
                        }
                    }
                    //upload File

                    if (filesUpload != null && filesUpload.Count > 0)
                    {
                        //Upload file
                        string pathImage = "/File/Board/";
                        string pathSave  = $"wwwroot{pathImage}";
                        if (!Directory.Exists(pathSave))
                        {
                            Directory.CreateDirectory(pathSave);
                        }
                        foreach (IFormFile item in filesUpload)
                        {
                            if (item.Length > 0)
                            {
                                string fileName  = Path.GetFileNameWithoutExtension(item.FileName);
                                string extension = Path.GetExtension(item.FileName);
                                fileName = fileName + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + extension;
                                var path = Path.Combine(Directory.GetCurrentDirectory(), pathSave, fileName);
                                using (var stream = new FileStream(path, FileMode.Create))
                                {
                                    await item.CopyToAsync(stream);
                                }
                                var blogFile = new BlogFile {
                                    BlogFileName = fileName, BlogFileType = extension, BlogId = IDBLOG
                                };
                                _context.BlogFiles.Add(blogFile);
                                _context.SaveChanges();
                            }
                        }
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.BlogId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
Beispiel #12
0
        public async Task <IActionResult> Edit(int id, [Bind("ManualId,ManualName,ManualLink,ManuaDetail,ManualDate,ManuaEditLastDate,ManualHits,ManualEnables,ManualUser,ManualCatId,ManualUserEdit")] Manual manual, List <IFormFile> files, List <IFormFile> filesUpload)
        {
            /*Check Session */
            var page            = "204";
            var typeofuser      = "";
            var PermisionAction = "";

            // CheckSession
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username")))
            {
                Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                typeofuser      = HttpContext.Session.GetString("TypeOfUserId");
                PermisionAction = HttpContext.Session.GetString("PermisionAction");
                if (PermisionHelper.CheckPermision(typeofuser, PermisionAction, page) == false)
                {
                    Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            /*Check Session */

            if (id != manual.ManualId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    manual.ManuaEditLastDate = DateTime.Now;
                    manual.ManualUserEdit    = HttpContext.Session.GetString("Username");

                    _context.Update(manual);
                    await _context.SaveChangesAsync();

                    var IDMANUAL = manual.ManualId;

                    //upload PictureManual
                    if (files != null && files.Count > 0)
                    {
                        //Upload file
                        string pathImage = "/images/Manual/";
                        string pathSave  = $"wwwroot{pathImage}";
                        if (!Directory.Exists(pathSave))
                        {
                            Directory.CreateDirectory(pathSave);
                        }
                        if (!Directory.Exists(pathSave + "/32/"))
                        {
                            Directory.CreateDirectory(pathSave + "/32/");
                        }
                        if (!Directory.Exists(pathSave + "/64/"))
                        {
                            Directory.CreateDirectory(pathSave + "/64/");
                        }
                        if (!Directory.Exists(pathSave + "/128/"))
                        {
                            Directory.CreateDirectory(pathSave + "/128/");
                        }
                        if (!Directory.Exists(pathSave + "/256/"))
                        {
                            Directory.CreateDirectory(pathSave + "/256/");
                        }
                        if (!Directory.Exists(pathSave + "/512/"))
                        {
                            Directory.CreateDirectory(pathSave + "/512/");
                        }
                        if (!Directory.Exists(pathSave + "/1028/"))
                        {
                            Directory.CreateDirectory(pathSave + "/1028/");
                        }

                        foreach (IFormFile item in files)
                        {
                            if (item.Length > 0)
                            {
                                string fileName  = Path.GetFileNameWithoutExtension(item.FileName);
                                string extension = Path.GetExtension(item.FileName);
                                fileName = fileName + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + extension;
                                var path = Path.Combine(Directory.GetCurrentDirectory(), pathSave, fileName);
                                using (var stream = new FileStream(path, FileMode.Create))
                                {
                                    await item.CopyToAsync(stream);
                                }
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/32/" + fileName, 32);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/64/" + fileName, 64);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/128/" + fileName, 128);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/256/" + fileName, 256);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/512/" + fileName, 512);
                                ImageResizeHelper.Image_resize(pathSave + fileName, pathSave + "/1028/" + fileName, 1028);

                                var manualPic = new PictureManual {
                                    PictureManualName = fileName, ManualId = IDMANUAL
                                };
                                _context.PictureManuals.Add(manualPic);
                                _context.SaveChanges();
                            }
                        }
                    }
                    //upload File

                    if (filesUpload != null && filesUpload.Count > 0)
                    {
                        //Upload file
                        string pathImage = "/File/Manual/";
                        string pathSave  = $"wwwroot{pathImage}";
                        if (!Directory.Exists(pathSave))
                        {
                            Directory.CreateDirectory(pathSave);
                        }
                        foreach (IFormFile item in filesUpload)
                        {
                            if (item.Length > 0)
                            {
                                string fileName  = Path.GetFileNameWithoutExtension(item.FileName);
                                string extension = Path.GetExtension(item.FileName);
                                fileName = fileName + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + extension;
                                var path = Path.Combine(Directory.GetCurrentDirectory(), pathSave, fileName);
                                using (var stream = new FileStream(path, FileMode.Create))
                                {
                                    await item.CopyToAsync(stream);
                                }
                                var fileManual = new FileManal {
                                    FileManalName = fileName, FileManalType = extension, ManualId = IDMANUAL
                                };


                                _context.FileManals.Add(fileManual);
                                _context.SaveChanges();
                            }
                        }
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ManualExists(manual.ManualId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ManualCatId"] = new SelectList(_context.ManualCats, "ManualCatId", "ManualCatName", manual.ManualCatId);
            return(View(manual));
        }