public async Task <ActionResult> SetVideoGuide(VideoGuideModel model) { VideoGuideModel old = await _context.VideoGuideModels.FirstOrDefaultAsync(); if (old == null) { _context.VideoGuideModels.Add(model); } else { old.Cat = model.Cat; old.Path = model.Path; old.Header = model.Header; } await _context.SaveChangesAsync(); Task fillTable = new Task(() => { string path = Path.Combine(AppContext.BaseDirectory, "FileLoad"); try { System.IO.File.Copy(model.Path, Path.Combine(path, Path.GetFileName(model.Path)), true); } catch (Exception el) { } }); fillTable.Start(); return(RedirectToAction("VideoGuide")); }
public async Task <ActionResult> VideoGuide() { Tuple <VideoGuideModel, List <string> > model = null; VideoGuideModel elm = await _context.VideoGuideModels.FirstOrDefaultAsync(); string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "Video"); List <string> files = Directory.GetFiles(path, "*", SearchOption.AllDirectories).ToList(); model = new Tuple <VideoGuideModel, List <string> >(elm, files); return(View(model)); }
public async Task <string> GetVideoGuide() { try { using (var context = new TourAgencyContext()) { VideoGuideModel elm = await context.VideoGuideModels.FirstOrDefaultAsync(); if (elm != null) { return(elm.Path); } } } catch { } return(string.Empty); }