コード例 #1
0
        public MediaData UploadCustomMediaINIT(long file_size_bytes, MediaCategory mediaCategory)
        {
            var parameters = new Dictionary <string, object> {
            };

            parameters.Add("total_bytes", file_size_bytes);
            parameters.Add("media_category", mediaCategory);
            parameters.Add("media_type", GetMediaTypeByMediaCategory(mediaCategory));

            var response = APIHandler.requestAPIOAuthAsync("https://upload.twitter.com/1.1/media/upload.json?command=INIT", APIHandler.Method.POST, parameters);

            var media_data = new MediaData(JObject.Parse(response.Result));

            return(media_data);
        }
コード例 #2
0
        static GoodMergeMetadataExtractor()
        {
            IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();

            if (!mediaAccessor.MediaCategories.TryGetValue(GOODMERGE_CATEGORY_NAME, out _goodmergeCategory))
            {
                _goodmergeCategory = mediaAccessor.RegisterMediaCategory(GOODMERGE_CATEGORY_NAME, new List <MediaCategory> {
                    GameMetadataExtractor.GameMediaCategory
                });
            }
            MEDIA_CATEGORIES.Add(_goodmergeCategory);
            // All non-default media item aspects must be registered
            IMediaItemAspectTypeRegistration miatr = ServiceRegistration.Get <IMediaItemAspectTypeRegistration>();

            miatr.RegisterLocallyKnownMediaItemAspectTypeAsync(GoodMergeAspect.Metadata);
        }
コード例 #3
0
    public AddMediaCategoryResponse HandleRequest(AddMediaCategoryRequest request)
    {
        MediaCategory parentCategory = null;
        MediaCategory mediaCategory  = new MediaCategory(request.Description, request.Label, false);
        Guid          id             = _mediaCategoryRepository.Save(mediaCategory);

        if (request.ParentCategory != Guid.Empty)
        {
            parentCategory = _mediaCategoryRepository.Get(request.ParentCategory);
            parentCategory.AddCategoryTo(mediaCategory);
        }
        AddMediaCategoryResponse response = new AddMediaCategoryResponse();

        response.ID = id;
        return(response);
    }
コード例 #4
0
        /// <summary>
        /// Upload Custom media from bytes and MediaCategory enum
        /// </summary>
        public static MediaData UploadCustomMediaFromBytesStatic(byte[] dataBytes, MediaCategory mediaCategory)
        {
            //Load File Data
            string encodedFileAsBase64 = Convert.ToBase64String(dataBytes);

            //INIT Media call
            var media_init = UploadCustomMediaINITStatic(dataBytes.Length, mediaCategory);

            //APPEND Media call
            UploadCustomMediaAPPENDStatic(encodedFileAsBase64, media_init);

            //FINALIZE Media call
            var media_data = UploadCustomMediaFINALIZEStatic(media_init);

            return(media_data);
        }
コード例 #5
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            AddJS("MediaManagement", "/cbuilderassets/js/SageMediaManagement.js");
            AddCSS("MediaMgmt", "/cbuilderassets/css/MediaManagement.css");

            MediaLibraryInfo libraryInfo   = new MediaLibraryInfo();
            MediaCategory    mediaCategory = new MediaCategory(); //Get Username here later

            MediaSettingController settingController = new MediaSettingController();
            MediaSettingKeys       mediaSettingKeys  = await settingController.GetMediaSettingKeyValue();

            libraryInfo.MediaSettingKeys = mediaSettingKeys;
            libraryInfo.MediaFolderList  = MediaHelper.GetMediaFolderList(mediaCategory, mediaSettingKeys);
            PackMediaJs();

            return(await Task.FromResult((IViewComponentResult)View("Default", libraryInfo)));
        }
コード例 #6
0
        public JsonResult Files_Post([IoCModelBinder(typeof(NullableEntityModelBinder))] MediaCategory mediaCategory)
        {
            var list = new List <ViewDataUploadFilesResult>();

            foreach (string files in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[files];
                if (_fileService.IsValidFileType(file.FileName))
                {
                    ViewDataUploadFilesResult dbFile = _fileService.AddFile(file.InputStream, file.FileName,
                                                                            file.ContentType, file.ContentLength,
                                                                            mediaCategory);
                    list.Add(dbFile);
                }
            }
            return(Json(list.ToArray(), "text/html", Encoding.UTF8));
        }
コード例 #7
0
        public void DeleteFoldersSoft(IEnumerable <MediaCategory> folders)
        {
            if (folders != null)
            {
                IEnumerable <MediaCategory> foldersRecursive = GetFoldersRecursive(folders);
                foreach (MediaCategory f in foldersRecursive)
                {
                    MediaCategory    folder = _documentService.GetDocument <MediaCategory>(f.Id);
                    List <MediaFile> files  = folder.Files.ToList();
                    foreach (MediaFile file in files)
                    {
                        _fileService.DeleteFileSoft(file);
                    }

                    _documentService.DeleteDocument(folder);
                }
            }
        }
コード例 #8
0
        public void Setup()
        {
            _session.Transact(session =>
            {
                var defaultMediaCategory = new MediaCategory
                {
                    Name       = "Default",
                    UrlSegment = "default",
                };
                session.Save(defaultMediaCategory);

                string logoPath  = HttpContext.Current.Server.MapPath("/Apps/Core/Content/images/logo.png");
                var fileStream   = new FileStream(logoPath, FileMode.Open);
                MediaFile dbFile = _fileService.AddFile(fileStream, Path.GetFileName(logoPath), "image/png",
                                                        fileStream.Length,
                                                        defaultMediaCategory);
            });
        }
コード例 #9
0
        public async Task <ApiResponse> Handle(AddEditMediaCategoryCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                if (request.MediaCategoryId == 0 || request.MediaCategoryId == null)
                {
                    MediaCategory obj = new MediaCategory();
                    obj.CreatedById  = request.CreatedById;
                    obj.CreatedDate  = request.CreatedDate;
                    obj.IsDeleted    = false;
                    obj.CategoryName = request.CategoryName;
                    _mapper.Map(request, obj);
                    await _dbContext.MediaCategories.AddAsync(obj);

                    await _dbContext.SaveChangesAsync();

                    response.StatusCode             = StaticResource.successStatusCode;
                    response.Message                = "Media Category Added successfully";
                    response.data.mediaCategoryById = obj;
                }
                else
                {
                    MediaCategory obj = await _dbContext.MediaCategories.FirstOrDefaultAsync(x => x.MediaCategoryId == request.MediaCategoryId);

                    obj.ModifiedById = request.ModifiedById;
                    obj.ModifiedDate = request.ModifiedDate;
                    _mapper.Map(request, obj);
                    await _dbContext.SaveChangesAsync();

                    response.data.mediaCategoryById = obj;
                    response.StatusCode             = StaticResource.successStatusCode;
                    response.Message = "Media Category updated successfully";
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
コード例 #10
0
        public async Task <ApiResponse> Handle(GetMediaCategoryByIdQuery request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                MediaCategory obj = await _dbContext.MediaCategories.AsNoTracking().AsQueryable().Where(x => x.MediaCategoryId == request.MediaCategoryId && x.IsDeleted == false).SingleAsync();

                response.data.mediaCategoryById = obj;
                response.StatusCode             = StaticResource.successStatusCode;
                response.Message = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
コード例 #11
0
        public bool UrlIsValidForMediaCategory(string url, int?id)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(false);
            }

            if (id.HasValue)
            {
                MediaCategory document = _session.Get <MediaCategory>(id.Value);
                if (url.Trim() == document.UrlSegment.Trim())
                {
                    return(true);
                }
                return(!MediaCategoryExists(url));
            }

            return(!MediaCategoryExists(url));
        }
コード例 #12
0
        public void Execute(OnAddingArgs <Product> args)
        {
            var product = args.Item;

            if (!product.Variants.Any())
            {
                var productVariant = new ProductVariant
                {
                    Name           = product.Name,
                    TrackingPolicy = TrackingPolicy.DontTrack,
                };
                product.Variants.Add(productVariant);
                productVariant.Product = product;
                _session.Transact(s => s.Save(productVariant));
            }

            var mediaCategory = _documentService.GetDocumentByUrl <MediaCategory>("product-galleries");

            if (mediaCategory == null)
            {
                mediaCategory = new MediaCategory
                {
                    Name           = "Product Galleries",
                    UrlSegment     = "product-galleries",
                    IsGallery      = true,
                    HideInAdminNav = true
                };
                _documentService.AddDocument(mediaCategory);
            }
            var productGallery = new MediaCategory
            {
                Name           = product.Name,
                UrlSegment     = "product-galleries/" + product.UrlSegment,
                IsGallery      = true,
                Parent         = mediaCategory,
                HideInAdminNav = true
            };

            product.Gallery = productGallery;

            _documentService.AddDocument(productGallery);
        }
コード例 #13
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube Feed object</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeRatingsTest()
        {
            Tracing.TraceMsg("Entering YouTubeRatingsTest");

            YouTubeService service = new YouTubeService("NETUnittests", this.ytDevKey);

            if (this.userName != null)
            {
                service.Credentials = new GDataCredentials(this.ytUser, this.ytPwd);
            }

            YouTubeEntry entry = new YouTubeEntry();

            entry.MediaSource       = new MediaFileSource(this.resourcePath + "test_movie.mov", "video/quicktime");
            entry.Media             = new YouTube.MediaGroup();
            entry.Media.Description = new MediaDescription("This is a test");
            entry.Media.Title       = new MediaTitle("Sample upload");
            entry.Media.Keywords    = new MediaKeywords("math");

            // entry.Media.Categories

            MediaCategory category = new MediaCategory("Nonprofit");

            category.Attributes["scheme"] = YouTubeService.DefaultCategory;

            entry.Media.Categories.Add(category);

            YouTubeEntry newEntry = service.Upload(this.ytUser, entry);

            Assert.AreEqual(newEntry.Media.Description.Value, entry.Media.Description.Value, "Description should be equal");
            Assert.AreEqual(newEntry.Media.Keywords.Value, entry.Media.Keywords.Value, "Keywords should be equal");


            Rating rating = new Rating();

            rating.Value    = 1;
            newEntry.Rating = rating;

            YouTubeEntry ratedEntry = newEntry.Update();

            ratedEntry.Delete();
        }
コード例 #14
0
 public ActionResult Create(CreateMediaCategoriesViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var category = new MediaCategory
             {
                 Name = model.Name
             };
             repository.Add(category);
             return(RedirectToAction("index"));
         }
         return(View(model));
     }
     catch
     {
         return(View());
     }
 }
コード例 #15
0
 public ActionResult Edit(int id, EditMediaCategoriesViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var category = new MediaCategory
             {
                 Name = model.Name
             };
             repository.Update(model.Id, category);
             return(RedirectToAction("index"));
         }
         return(View(model));
     }
     catch
     {
         return(View(model));
     }
 }
コード例 #16
0
        public static async Task <MediaCapture> Init(MediaCategory mediaCategory, AudioProcessing audioProcessingType)
        {
            await MicrophoneHandler.EnableMicrophone();

            var mediaCapture = new MediaCapture();
            var devices      = await DeviceInformation.FindAllAsync(DeviceClass.AudioCapture);

            var device       = devices[0];
            var microphoneId = device.Id;

            await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
            {
                MediaCategory        = mediaCategory,
                StreamingCaptureMode = StreamingCaptureMode.Audio,
                AudioDeviceId        = microphoneId,
                AudioProcessing      = audioProcessingType
            });

            return(mediaCapture);
        }
コード例 #17
0
        private MediaCategory GetProductGallery()
        {
            var gallery = new MediaCategory()
            {
                Id   = 1,
                Name = "Product Gallery"
            };
            var mediaFile = new MediaFile
            {
                FileUrl       = "http://www.thought.co.uk/Content/images/logo-white.png",
                FileName      = "logo-white.png",
                ContentType   = "image/png",
                MediaCategory = gallery,
                FileExtension = Path.GetExtension("logo-white.png")
            };

            gallery.Files.Add(mediaFile);

            return(gallery);
        }
コード例 #18
0
ファイル: CategoryPageModel.cs プロジェクト: jmckniff/Peep
        private MediaCategory GetMovieMediaCategory(string categoryName)
        {
            var category = new MediaCategory(categoryName);

            var moviePortraitLinks = _webDriver.FindAll(".asset-item-component__link");

            foreach (var link in moviePortraitLinks)
            {
                var relativeUrl = link.GetAttribute("href");
                var portrait    = link.FindElement(By.CssSelector(".aspect-ratio-image__img"));
                var name        = portrait.GetAttribute("alt");

                var movie = new Media(name);
                movie.SetRelativeUrl(relativeUrl);
                movie.MakeAvailable();

                category.AddMedia(movie);
            }

            return(category);
        }
コード例 #19
0
        public Media ConvertToMedia(List <MediaCategory> mediaCategories, List <RatingCategory> ratingCategories)
        {
            Media Result = new Media();

            Result.MediaId   = MediaId != Guid.Empty ? MediaId : Guid.NewGuid();
            Result.EditedOn  = EditedOn ?? DateTime.Now;
            Result.MediaType = MediaType;
            Result.Artist    = Artist ?? string.Empty;
            Result.Album     = Album ?? string.Empty;
            Result.Title     = Title;
            if (!string.IsNullOrEmpty(Category))
            {
                MediaCategory ItemCategory = mediaCategories.FirstOrDefault(v => v.Name == Category && v.MediaTypeId == (int)MediaType);
                if (ItemCategory != null)
                {
                    Result.MediaCategoryId = ItemCategory.MediaCategoryId;
                }
            }
            Result.Preference   = Preference;
            Result.Length       = Length;
            Result.StartPos     = StartPos;
            Result.EndPos       = EndPos;
            Result.DownloadName = DownloadName ?? string.Empty;
            Result.DownloadUrl  = DownloadUrl ?? string.Empty;
            Result.BuyUrl       = BuyUrl ?? string.Empty;

            MediaRating NewRating;

            foreach (SyncRating item in Ratings)
            {
                NewRating          = new MediaRating();
                NewRating.MediaId  = Result.MediaId;
                NewRating.RatingId = ratingCategories.FirstOrDefault(r => r.Name == item.Name).RatingId;
                NewRating.Height   = (item.Height != -1 ? (double?)item.Height : null);
                NewRating.Depth    = (item.Depth != -1 ? (double?)item.Depth : null);
                Result.MediaRatings.Add(NewRating);
            }

            return(Result);
        }
コード例 #20
0
        protected void UpdateMediaCategories(List <EmulatorConfiguration> configurations)
        {
            if (configurations == null || configurations.Count == 0)
            {
                return;
            }

            IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();

            foreach (EmulatorConfiguration configuration in configurations)
            {
                foreach (string platform in configuration.Platforms)
                {
                    if (!mediaAccessor.MediaCategories.ContainsKey(platform))
                    {
                        Logger.Debug("GamesMetadataExtractor: Adding Game Category {0}", platform);
                        MediaCategory category = mediaAccessor.RegisterMediaCategory(platform, new[] { _gameCategory });
                        _platformCategories.TryAdd(platform, category);
                    }
                }
            }
        }
コード例 #21
0
        public async Task <string> MoveMedia([FromBody] MediaCategory objMediaCategory)
        {
            string message = string.Empty;
            MediaSettingController mediaSettingController = new MediaSettingController();
            MediaSettingKeys       mediaSettingKeys       = await mediaSettingController.GetMediaSettingKeyValue();

            string[] extensions = { };
            string   rootPath   = MediaHelper.GetRootPath(mediaSettingKeys, objMediaCategory, out extensions);

            if (objMediaCategory.BaseCategory.ToLower() != objMediaCategory.ParentCategory.ToLower())
            {
                if (objMediaCategory.UploadType == "category")
                {
                    if (objMediaCategory.BaseCategory.ToLower().IndexOf(rootPath.ToLower()) > -1 && objMediaCategory.ParentCategory.ToLower().IndexOf(rootPath.ToLower()) > -1)
                    {
                        message = MediaHelper.MoveMediaCategory(objMediaCategory.BaseCategory, objMediaCategory.ParentCategory);
                        MediaHelper.MoveMediaFile(MediaHelper.originalThumbPath + objMediaCategory.BaseCategory, MediaHelper.originalThumbPath + objMediaCategory.ParentCategory);
                        MediaHelper.MoveMediaFile(MediaHelper.largeThumbPath + objMediaCategory.BaseCategory, MediaHelper.largeThumbPath + objMediaCategory.ParentCategory);
                        MediaHelper.MoveMediaFile(MediaHelper.mediumThumbPath + objMediaCategory.BaseCategory, MediaHelper.mediumThumbPath + objMediaCategory.ParentCategory);
                    }
                }
                else
                {
                    if (objMediaCategory.BaseCategory.ToLower().IndexOf(rootPath.ToLower()) > -1 && objMediaCategory.ParentCategory.ToLower().IndexOf(rootPath.ToLower()) > -1)
                    {
                        message = MediaHelper.MoveMediaFile(objMediaCategory.BaseCategory, objMediaCategory.ParentCategory);
                        string ext = MediaHelper.GetFileExtension(objMediaCategory.BaseCategory);
                        if (ext == "jpg" || ext == "png" || ext == "jpeg")
                        {
                            MediaHelper.MoveMediaFile(MediaHelper.originalThumbPath + objMediaCategory.BaseCategory, MediaHelper.originalThumbPath + objMediaCategory.ParentCategory);
                            MediaHelper.MoveMediaFile(MediaHelper.largeThumbPath + objMediaCategory.BaseCategory, MediaHelper.largeThumbPath + objMediaCategory.ParentCategory);
                            MediaHelper.MoveMediaFile(MediaHelper.mediumThumbPath + objMediaCategory.BaseCategory, MediaHelper.mediumThumbPath + objMediaCategory.ParentCategory);
                        }
                    }
                }
            }

            return(message);
        }
コード例 #22
0
        public bool RenameFileName([FromBody] MediaCategory objMediaCategory)
        {
            bool isExists = false;

            string newCategory = objMediaCategory.NewCategory;


            isExists = MediaHelper.RenameFileName(objMediaCategory.ParentCategory + "/" + objMediaCategory.BaseCategory, objMediaCategory.ParentCategory + "/" + newCategory);
            string ext = MediaHelper.GetFileExtension(objMediaCategory.BaseCategory);

            if (ext == "jpg" || ext == "png" || ext == "jpeg")
            {
                string pathStr = MediaHelper.largeThumbPath + objMediaCategory.ParentCategory + "/";
                MediaHelper.RenameFileName(pathStr + objMediaCategory.BaseCategory, pathStr + newCategory);
                pathStr = MediaHelper.mediumThumbPath + objMediaCategory.ParentCategory + "/";
                MediaHelper.RenameFileName(pathStr + objMediaCategory.BaseCategory, pathStr + newCategory);
                pathStr = MediaHelper.originalThumbPath + objMediaCategory.ParentCategory + "/";
                MediaHelper.RenameFileName(pathStr + objMediaCategory.BaseCategory, pathStr + newCategory);
            }

            return(isExists);
        }
コード例 #23
0
        public JsonResult CreateCategory([FromBody] MediaCategory mediaCategory)
        {
            //MediaCategory mediaCategory = new MediaCategory();


            //mediaCategory.BaseCategory = bPath;
            //mediaCategory.ParentCategory = pCategory;


            bool   isExists = false;
            string basePath = "/";

            if (mediaCategory.ParentCategory.Length > 0)
            {
                basePath += mediaCategory.ParentCategory + "/";
            }
            basePath += mediaCategory.BaseCategory;

            isExists = MediaHelper.CreateCategory(basePath);

            return(Json(isExists));
        }
コード例 #24
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                MediaCategory s = new MediaCategory();
                s.recordId = index;
                s.name     = "";
                PostRequest <MediaCategory> req = new PostRequest <MediaCategory>();
                req.entity = s;
                PostResponse <MediaCategory> r = _mediaGalleryService.ChildDelete <MediaCategory>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    Store1.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
コード例 #25
0
        /// <summary>
        /// Add Product Images
        /// </summary>
        /// <param name="dataTransferObject"></param>
        /// <param name="product"></param>
        public IEnumerable <MediaFile> ImportProductImages(List <string> images, MediaCategory mediaCategory)
        {
            // We want to always look at all of the urls in the file, and only not import when it is set to update = no
            foreach (var imageUrl in images)
            {
                Uri result;
                if (Uri.TryCreate(imageUrl, UriKind.Absolute, out result))
                {
                    // substring(1) should remove the leading ?
                    if (!String.IsNullOrWhiteSpace(result.Query))
                    {
                        if (result.Query.Contains("update=no"))
                        {
                            continue;
                        }
                    }
                    var resultWithOutQuery = !string.IsNullOrEmpty(result.Query) ? result.ToString().Replace(result.Query, "") : result.ToString();
                    ImportImageToGallery(resultWithOutQuery, mediaCategory);
                }
            }

            return(mediaCategory.Files);
        }
コード例 #26
0
        public IActionResult Edit(MediaCategory model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel))
            {
                return(AccessDeniedView());
            }

            var MediaCategory = _MediaCategoryService.GetMediaCategoryById(model.Id);

            if (MediaCategory == null)
            {
                return(RedirectToAction("Configure"));
            }


            MediaCategory.MediaCategoryName      = model.MediaCategoryName;
            MediaCategory.MediaCategoryLatinName = model.MediaCategoryLatinName;
            MediaCategory.MediaCategoryCode      = model.MediaCategoryCode;

            _MediaCategoryService.UpdateMediaCategory(MediaCategory);
            ViewBag.RefreshPage = true;
            return(View("~/Plugins/Company.Media/Views/MediaCategory/Edit.cshtml", model));
        }
コード例 #27
0
        public List <ImageSortItem> GetFilesToSort(MediaCategory category = null)
        {
            IQueryOver <MediaFile, MediaFile> query = _session.QueryOver <MediaFile>();

            query = category != null
                ? query.Where(file => file.MediaCategory.Id == category.Id)
                : query.Where(file => file.MediaCategory == null);

            query = query.OrderBy(x => x.DisplayOrder).Asc;

            ImageSortItem item = null;

            return(query.SelectList(builder =>
            {
                builder.Select(file => file.FileName).WithAlias(() => item.Name);
                builder.Select(file => file.Id).WithAlias(() => item.Id);
                builder.Select(file => file.DisplayOrder).WithAlias(() => item.Order);
                builder.Select(file => file.FileExtension).WithAlias(() => item.FileExtension);
                builder.Select(file => file.FileUrl).WithAlias(() => item.ImageUrl);
                return builder;
            }).TransformUsing(Transformers.AliasToBean <ImageSortItem>())
                   .List <ImageSortItem>().ToList());
        }
コード例 #28
0
        public IActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel))
            {
                return(AccessDeniedView());
            }

            var MediaCategory = _MediaCategoryService.GetMediaCategoryById(id);

            if (MediaCategory == null)
            {
                return(RedirectToAction("Configure"));
            }

            var model = new MediaCategory
            {
                Id = MediaCategory.Id,
                MediaCategoryName      = MediaCategory.MediaCategoryName,
                MediaCategoryLatinName = MediaCategory.MediaCategoryLatinName,
                MediaCategoryCode      = MediaCategory.MediaCategoryCode,
            };

            return(View("~/Plugins/Company.Media/Views/MediaCategory/Edit.cshtml", model));
        }
コード例 #29
0
        private IEnumerable <MediaCategory> GetMediaCategoryCopies(Site @from, Site to, SiteCloneContext siteCloneContext, MediaCategory fromParent = null, MediaCategory toParent = null)
        {
            IQueryOver <MediaCategory, MediaCategory> queryOver =
                _session.QueryOver <MediaCategory>().Where(layout => layout.Site.Id == @from.Id);

            queryOver = fromParent == null
                ? queryOver.Where(layout => layout.Parent == null)
                : queryOver.Where(layout => layout.Parent.Id == fromParent.Id);

            IList <MediaCategory> categories = queryOver.List();

            foreach (MediaCategory category in categories)
            {
                MediaCategory copy = category.GetCopyForSite(to);
                siteCloneContext.AddEntry(category, copy);
                copy.Parent = toParent;
                yield return(copy);

                foreach (MediaCategory child in GetMediaCategoryCopies(@from, to, siteCloneContext, fromParent: category, toParent: copy))
                {
                    yield return(child);
                }
            }
        }
コード例 #30
0
        public JsonResult RenameCategory([FromBody] MediaCategory objMediaCategory)
        {
            bool isExists = false;

            string basePath = "/";

            if (objMediaCategory.ParentCategory.Length > 0)
            {
                basePath += objMediaCategory.ParentCategory + "/";
            }
            string newCategory = objMediaCategory.NewCategory;

            isExists = MediaHelper.RenameCategory(objMediaCategory.ParentCategory + "/" + objMediaCategory.BaseCategory, objMediaCategory.ParentCategory + "/" + newCategory);
            string ext     = MediaHelper.GetFileExtension(objMediaCategory.BaseCategory);
            string pathStr = MediaHelper.largeThumbPath + objMediaCategory.ParentCategory + "/";

            MediaHelper.RenameCategory(pathStr + objMediaCategory.BaseCategory, pathStr + newCategory);
            pathStr = MediaHelper.mediumThumbPath + objMediaCategory.ParentCategory + "/";
            MediaHelper.RenameCategory(pathStr + objMediaCategory.BaseCategory, pathStr + newCategory);
            pathStr = MediaHelper.originalThumbPath + objMediaCategory.ParentCategory + "/";
            MediaHelper.RenameCategory(pathStr + objMediaCategory.BaseCategory, pathStr + newCategory);

            return(Json(isExists));
        }
コード例 #31
0
 public void Delete(MediaCategory entity)
 {
     this.categories.Delete(entity);
     this.categories.Save();
 }
コード例 #32
0
 public void Update(MediaCategory entity)
 {
     this.categories.Update(entity);
     this.categories.Save();
 }
コード例 #33
0
        internal static void SeedMediaCategory(EntertainmentSystemDbContext context)
        {
            if (context.MediaCategories.Any())
            {
                return;
            }

            var category = new MediaCategory
            {
                Name = "Action"
            };

            context.MediaCategories.Add(category);
            context.SaveChanges();
        }
コード例 #34
0
        public void Should_Swap_Original_And_Reuploaded_Entities_Correctly()
        {
            var original = TestDataProvider.CreateNewMediaFile();
            var newVersion = TestDataProvider.CreateNewMediaFile();

            var origTitle = original.Title;
            var newVersionTitle = newVersion.Title;

            var cat11 = TestDataProvider.CreateNewCategory(new CategoryTree());
            var cat12 = TestDataProvider.CreateNewCategory(new CategoryTree());
            var cat21 = TestDataProvider.CreateNewCategory(new CategoryTree());

            var mcCat11 = new MediaCategory {Category = cat11, Media = original};
            var mcCat12 = new MediaCategory {Category = cat12, Media = original};
            var mcCat21 = new MediaCategory { Category = cat21, Media = newVersion };

            var tag11 = TestDataProvider.CreateNewTag();
            var tag12 = TestDataProvider.CreateNewTag();
            var tag21 = TestDataProvider.CreateNewTag();

            var mtTag11 = new MediaTag { Tag = tag11, Media = newVersion };
            var mtTag12 = new MediaTag { Tag = tag12, Media = newVersion };
            var mtTag21 = new MediaTag { Tag = tag21, Media = original };

            original.Categories = new List<MediaCategory>();
            newVersion.Categories = new List<MediaCategory>();
            original.MediaTags = new List<MediaTag>();
            newVersion.MediaTags = new List<MediaTag>();

            original.Categories.Add(mcCat11);
            original.Categories.Add(mcCat12);
            newVersion.Categories.Add(mcCat21);

            newVersion.MediaTags.Add(mtTag11);
            newVersion.MediaTags.Add(mtTag12);
            original.MediaTags.Add(mtTag21);

            var service = GetMediaFileService(false);
            service.SwapOriginalMediaWithVersion(original, newVersion);

            // Ensure etity properies are switched
            Assert.AreNotEqual(original.Title, newVersion.Title);
            Assert.AreEqual(origTitle, newVersion.Title);
            Assert.AreEqual(newVersionTitle, original.Title);

            // Ensure original entity is set correctly
            Assert.AreEqual(newVersion.Original, original);

            // Ensure categories are switched correctly
            Assert.AreEqual(original.Categories.Count, 1);
            Assert.AreEqual(newVersion.Categories.Count, 2);

            Assert.IsTrue(newVersion.Categories.Contains(mcCat11));
            Assert.IsTrue(newVersion.Categories.Contains(mcCat12));
            Assert.IsTrue(original.Categories.Contains(mcCat21));
            
            // Ensure tags are switched correctly
            Assert.AreEqual(original.MediaTags.Count, 2);
            Assert.AreEqual(newVersion.MediaTags.Count, 1);

            Assert.IsTrue(original.MediaTags.Contains(mtTag11));
            Assert.IsTrue(original.MediaTags.Contains(mtTag12));
            Assert.IsTrue(newVersion.MediaTags.Contains(mtTag21));
        }
コード例 #35
0
 public void Create(MediaCategory entity)
 {
     this.categories.Create(entity);
     this.categories.Save();
 }