public async Task <IActionResult> Edit(int id, [Bind("VidID,VidName,Author,VidDescription,Extension,CategoryID")] VideoLecDetail videoLecDetail)
        {
            if (id != videoLecDetail.VidID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(videoLecDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VideoLecDetailExists(videoLecDetail.VidID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(videoLecDetail));
        }
        public async Task <IActionResult> Create([Bind("VidID,VidName,Author,VidDescription,File,CategoryID")] VideoLecDetail videoLecDetail)
        {
            using (var memoryStream = new MemoryStream())
            {
                await videoLecDetail.File.FormFile.CopyToAsync(memoryStream);

                string photoname = videoLecDetail.File.FormFile.FileName;
                videoLecDetail.Extension = Path.GetExtension(photoname);
                if (!".mp4".Contains(videoLecDetail.Extension.ToLower()))
                {
                    ModelState.AddModelError("File.FormFile", "Only MP4 Format is Allowed.");
                }
                else
                {
                    ModelState.Remove("Extension");
                }
            }
            if (ModelState.IsValid)
            {
                _context.Add(videoLecDetail);
                await _context.SaveChangesAsync();

                var uploadsRootFolder = Path.Combine(_environment.WebRootPath, "videos");
                if (!Directory.Exists(uploadsRootFolder))
                {
                    Directory.CreateDirectory(uploadsRootFolder);
                }
                string filename = videoLecDetail.VidID + videoLecDetail.Extension;
                var    filePath = Path.Combine(uploadsRootFolder, filename);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    await videoLecDetail.File.FormFile.CopyToAsync(fileStream).ConfigureAwait(false);
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(videoLecDetail));
        }