예제 #1
0
        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");
        }
예제 #2
0
        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");
        }
예제 #3
0
 public void Delete(Media media)
 {
     context.Media.Attach(media);
     context.Media.Remove(media);
 }
예제 #4
0
 public void Update(Media media)
 {
     context.Media.Attach(media);
     context.Entry(media).State = EntityState.Modified;
 }
예제 #5
0
 public void Add(Media media)
 {
     context.Media.Add(media);
 }