public async Task <ActionResult <MediaItemDisplay> > PostAddFolder(PostedFolder folder) { var parentIdResult = await GetParentIdAsIntAsync(folder.ParentId, validatePermissions : true); if (!(parentIdResult.Result is null)) { return(new ActionResult <MediaItemDisplay>(parentIdResult.Result)); } var parentId = parentIdResult.Value; if (!parentId.HasValue) { return(NotFound("The passed id doesn't exist")); } var isFolderAllowed = IsFolderCreationAllowedHere(parentId.Value); if (isFolderAllowed == false) { return(ValidationProblem(_localizedTextService.Localize("speechBubbles", "folderCreationNotAllowed"))); } var f = _mediaService.CreateMedia(folder.Name, parentId.Value, Constants.Conventions.MediaTypes.Folder); _mediaService.Save(f, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id); return(_umbracoMapper.Map <MediaItemDisplay>(f)); }
public MediaItemDisplay PostAddFolder(PostedFolder folder) { var intParentId = GetParentIdAsInt(folder.ParentId, validatePermissions: true); var mediaService = Services.MediaService; var f = mediaService.CreateMedia(folder.Name, intParentId, Constants.Conventions.MediaTypes.Folder); mediaService.Save(f, Security.CurrentUser.Id); return(Mapper.Map <MediaItemDisplay>(f)); }
public MediaItemDisplay PostAddFolder(PostedFolder folder) { var intParentId = GetParentIdAsInt(folder.ParentId, validatePermissions: true); var mediaService = ApplicationContext.Services.MediaService; var f = mediaService.CreateMedia(folder.Name, intParentId, Constants.Conventions.MediaTypes.Folder); mediaService.Save(f, Security.CurrentUser.Id); return(AutoMapperExtensions.MapWithUmbracoContext <IMedia, MediaItemDisplay>(f, UmbracoContext)); }