Ejemplo n.º 1
0
 public void UpdateSlide(int id, Slide updated_slide)
 {
     Slide slide_to_update;
     if((slide_to_update = dbContext.Slides.Find(id)) != null)
     {
         slide_to_update.Name = updated_slide.Name;
         dbContext.Entry(slide_to_update).State = System.Data.Entity.EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public ActionResult UploadSlide(int playlistId, ViewModel_UploadSlideToPlaylist model)
 {
     for (int i = 0; i < Request.Files.Count; i++)
     {
         HttpPostedFileBase file = Request.Files[i]; //Uploaded file
                                                     //Use the following properties to get file's name, size and MIMEType
         try
         {
             switch (file.ContentType)
             {
                 case "image/png":
                 case "image/jpg":
                 case "image/jpeg":
                     var path = Path.Combine(
                                 Server.MapPath("/Content/Uploaded_Files/Slides/"),
                                 Path.GetFileName(file.FileName));
                     file.SaveAs(path); //File will be saved in application root
                     Slide slide = new Slide
                     {
                         Name = file.FileName,
                         Path = "/Content/Uploaded_Files/Slides/" + file.FileName,
                         ContentType = file.ContentType
                     };
                     slideService.InsertSlide(slide);
                     playlistService.ConnectSlide(playlistId, slide.SlideID);
                     model.statusList.Add(new UploadPostInfo()
                     {
                         filename = file.FileName,
                         imgsrc = "/content/images/ok.png",
                         message = "File added to database"
                     });
                     break;
                 default:
                     model.statusList.Add(new UploadPostInfo()
                     {
                         filename = file.FileName,
                         imgsrc = "/content/images/notok.png",
                         message = "File type is not supported"
                     });
                     break;
             }
         } catch (Exception ex)
         {
             model.statusList.Add(new UploadPostInfo()
             {
                 filename = file.FileName,
                 imgsrc = "/content/images/notok.png",
                 message = "Could not add to database, error:" + ex
             });
         }
     }
     return PartialView("~/Views/Playlists/_UploadSlideToPlaylistPartial.cshtml", model);
 }
Ejemplo n.º 3
0
 public ActionResult AddYoutube(int playlistId, ViewModel_AddYoutubeToPlaylist model)
 {
     string embedUrl = "";
     string[] urlparts = model.url.Split('/');
     foreach (string part in urlparts)
     {
         if (part == "https:" || part == "http:") { embedUrl += part + "//"; }
         else if (part == "www.youtube.com") { embedUrl += part + "/embed/"; }
         else if (part == "") { }
         else { embedUrl += part.Split('=')[1]; }
     }
     Slide slide = new Slide() { Name = model.name, ContentType = "youtube", Path = embedUrl };
     slideService.InsertSlide(slide);
     playlistService.ConnectSlide(playlistId, slide.SlideID);
     return RedirectToAction("Playlist", new { playlistId = playlistId });
 }
Ejemplo n.º 4
0
 public void InsertSlide(Slide slide)
 {
     dbContext.Slides.Add(slide);
     dbContext.SaveChanges();
 }