Beispiel #1
0
        public void Create(MultimediaTransitional entity)
        {
            Guard.WhenArgument(entity, GlobalConstants.MultimediaTransitionalRequiredExceptionMessage)
            .IsNull()
            .Throw();

            if (!entity.UrlPath.StartsWith(YouTubeUrlPathStart))
            {
                throw new ArgumentException(GlobalConstants.YouTubeRequiredExceptionMessage);
            }

            entity.Description = this.sanitizer.Sanitize(entity.Description);

            var imageId = entity.UrlPath
                          .Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();

            entity.ImageUrlPath = YouTubeImageUrlPathStart + imageId + YouTubeImageUrlPathEnd;

            Multimedia entityDb = this.modelDbFactory.CreateMultimedia(
                entity.Title,
                entity.Description,
                entity.UrlPath,
                entity.ImageUrlPath);

            this.multimedia.Create(entityDb);
            this.context.Save();
        }
Beispiel #2
0
        public void Delete(MultimediaTransitional entity)
        {
            Guard.WhenArgument(entity, GlobalConstants.MultimediaTransitionalRequiredExceptionMessage)
            .IsNull()
            .Throw();

            var entityDb = this.mapper.Map <Multimedia>(entity);

            this.multimedia.Delete(entityDb);
            this.context.Save();
        }