public ActionResult AddExternalImage(MultiMediaModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Media newExternalImage = new Media()
                    {
                        Path = model.ExternalImageURL,
                        UserId = ApplicationUser.Id,
                        IsInWaitingRoom = true,
                        MediaTypeDictId = ((DictionaryValue)cacheRepository.Get(Constants.MT_EXTERNAL_IMAGE)).Id,
                        Title = model.Title,
                        IsForAdults = model.IsForAdults
                    };

                    mediaRepository.Add(newExternalImage);
                    mediaRepository.Save();

                    string alertMessage = string.Empty;
                    alertMessage = string.Format("<b>{0}</b> external image was successfully added to the database!", newExternalImage.Title);
                    Success(alertMessage);
                }
                catch (Exception ex)
                {
                    Danger("An error occured, please try again later.");
                }
            }

            return RedirectToAction("Add");
        }
        public ActionResult AddYoutubeVideo(MultiMediaModel model)
        {
            if (ModelState.IsValid)
            {
                string alertMessage = string.Empty;

                try
                {
                    Media newYoutubeVideo = new Media()
                    {
                        Path = MediaHelper.ConvertYoutubeURL(model.VideoURL),
                        UserId = ApplicationUser.Id,
                        IsInWaitingRoom = true,
                        MediaTypeDictId = ((DictionaryValue)cacheRepository.Get(Constants.MT_YOUTUBE_VIDEO)).Id,
                        Title = model.Title,
                        IsForAdults = model.IsForAdults
                    };

                    mediaRepository.Add(newYoutubeVideo);
                    mediaRepository.Save();

                    alertMessage = string.Format("<b>{0}</b> youtube video was successfully added to the database!", newYoutubeVideo.Title);
                    Success(alertMessage);
                }
                catch (Exception ex)
                {
                    Danger("An error occured, please try again later.");
                }
            }

            return RedirectToAction("Add");
        }
 public void Delete(Media media)
 {
     context.Media.Attach(media);
     context.Media.Remove(media);
 }
 public void Update(Media media)
 {
     context.Media.Attach(media);
     context.Entry(media).State = EntityState.Modified;
 }
 public void Add(Media media)
 {
     context.Media.Add(media);
 }