public void CreateVideoSlide(GalleryVideoLang model)
 {
     using (var db = new DataContext())
     {
         var video = new GalleryVideo()
         {
             CreateDate = DateTime.Now
         };
         db.GalleryVideos.Add(video);
         var videoRu = new GalleryVideoLanguage()
         {
             GalleryVideoId = video.Id,
             LanguageId     = EnumLanguage.ru,
             Title          = model.Ru_Title,
             Video          = model.Ru_Video
         };
         db.GalleryVideoLanguages.Add(videoRu);
         var videoRo = new GalleryVideoLanguage()
         {
             GalleryVideoId = video.Id,
             LanguageId     = EnumLanguage.ro,
             Title          = model.Ro_Title,
             Video          = model.Ro_Video
         };
         db.GalleryVideoLanguages.Add(videoRo);
         db.SaveChanges();
     }
 }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GalleryVideo video = _repo.Get(id.Value);

            if (video == null)
            {
                return(HttpNotFound());
            }
            return(View(video));
        }
        public ActionResult Edit(GalleryVideo gallery, HttpPostedFileBase GalleryVideo, HttpPostedFileBase GalleryImage)
        {
            if (ModelState.IsValid)
            {
                #region Upload Video
                if (GalleryVideo != null)
                {
                    if (System.IO.File.Exists(Server.MapPath("/Files/GalleryVideos/" + gallery.Video)))
                    {
                        System.IO.File.Delete(Server.MapPath("/Files/GalleryVideos/" + gallery.Video));
                    }

                    var newFileName = Guid.NewGuid() + Path.GetExtension(GalleryVideo.FileName);
                    GalleryVideo.SaveAs(Server.MapPath("/Files/GalleryVideos/" + newFileName));
                    gallery.Video = newFileName;
                }
                #endregion
                #region Upload Image
                if (GalleryImage != null)
                {
                    if (System.IO.File.Exists(Server.MapPath("/Files/GalleryImages/" + gallery.Image)))
                    {
                        System.IO.File.Delete(Server.MapPath("/Files/GalleryImages/" + gallery.Image));
                    }

                    // Saving Temp Image
                    var newFileName = Guid.NewGuid() + Path.GetExtension(GalleryImage.FileName);
                    GalleryImage.SaveAs(Server.MapPath("/Files/GalleryImages/Temp/" + newFileName));

                    // Resizing Image
                    ImageResizer imageCut = new ImageResizer(1200, 1200, true);

                    imageCut.Resize(Server.MapPath("/Files/GalleryImages/Temp/" + newFileName),
                                    Server.MapPath("/Files/GalleryImages/" + newFileName));

                    // Deleting Temp Image
                    System.IO.File.Delete(Server.MapPath("/Files/GalleryImages/Temp/" + newFileName));
                    gallery.Image = newFileName;
                }
                #endregion
                _repo.Update(gallery);
                return(RedirectToAction("Index"));
            }
            return(View(gallery));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> AddVideos(IFormCollection formdata)
        {
            //await FFmpegDownloader.GetLatestVersion(FFmpegVersion.Official);
            //FFmpeg.SetExecutablesPath(@"D:\Downloads\Сане\ffmpeg-20200501-39fb1e9-win64-static\ffmpeg-20200501-39fb1e9-win64-static\bin");
            int    i             = 0;
            string GalleryPath   = env.WebRootPath + @"\Uploads\Videos";
            string dbGalleryPath = @"/Uploads/Videos";
            string VideoName     = "";

            foreach (var file in formdata.Files)
            {
                if (file.Length > 0)
                {
                    var    extension    = Path.GetExtension(file.FileName);
                    var    filename     = DateTime.Now.ToString("ddMMHHmmssfff");
                    var    path         = Path.Combine(GalleryPath, filename) + extension;
                    var    dbPath       = dbGalleryPath + "/" + filename + extension;
                    string VideoCaption = formdata["VideoCaption[]"][i];
                    VideoName = formdata["VideoName[]"][i];
                    GalleryVideo video = new GalleryVideo();
                    video.Caption  = VideoCaption;
                    video.VideoUrl = dbPath;
                    video.Name     = VideoName;
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    i++;
                    string thumbPath   = env.WebRootPath + @"\Uploads\Videos\Thumbnails\" + filename + ".jpeg";
                    string dbThumbPath = @"/Uploads/Videos/ThumbNails/" + filename + ".jpeg";
                    video.ThumbUrl = dbThumbPath;
                    await db.GalleryVideos.AddAsync(video);

                    IConversion conversion = await FFmpeg.Conversions.FromSnippet.Snapshot(path, thumbPath, TimeSpan.FromSeconds(0));

                    IConversionResult result = await conversion.Start();
                }
            }
            await db.SaveChangesAsync();

            return(new JsonResult("Видеофайл " + VideoName + " загружен"));
        }
Exemplo n.º 5
0
        public List <GalleryVideo> GetAllVideos(int companyId)
        {
            List <GalleryVideo> objListOfVideos = new List <GalleryVideo>();
            List <Pitch>        pitches         = _context.Pitches.ToList();

            foreach (var objPitch in pitches)
            {
                Delivery      objDelivery      = _context.Deliveries.Where(x => x.DeliveryId == objPitch.DeliveryId).SingleOrDefault();
                ScriptContent objScriptContent = _context.ScriptContents.Where(x => x.ScriptId == objPitch.ScriptId).SingleOrDefault();
                Script        objScript        = _context.Scripts.Where(x => x.ScriptId == objPitch.ScriptId).SingleOrDefault();

                GalleryVideo objGalleryVideo = new GalleryVideo
                {
                    ScriptContent = objScriptContent,
                    Delivery      = objDelivery,
                    PitchId       = objPitch.PitchId,
                    Script        = objScript
                };
                objListOfVideos.Add(objGalleryVideo);
            }
            return(objListOfVideos);
        }
Exemplo n.º 6
0
        public IActionResult ChosenVideo(int id)
        {
            GalleryVideo video = db.GalleryVideos.First(v => v.Id == id);

            return(new JsonResult(video));
        }