コード例 #1
0
ファイル: ResourceService.cs プロジェクト: war-man/SmartKiosk
        public async Task UpdateResourceTransactionAsync(Resource entity,
                                                         UpdateResourceModel model,
                                                         FileDestinationMetadata metadata = null)
        {
            if (model.Info != null)
            {
                model.Info.CopyTo(entity);
                if (model.Info.Image != null)
                {
                    await SetResourceImageUrlAsync(entity, model.Info.Image, metadata);
                }
                if (model.Info.Logo != null)
                {
                    await SetResourceLogoUrlAsync(entity, model.Info.Logo, metadata);
                }
            }
            if (model.NewResourceContents != null)
            {
                CreateResourceContents(model.NewResourceContents, entity);
            }
            if (model.UpdateResourceContents != null)
            {
                UpdateResourceContents(model.UpdateResourceContents, entity.Id);
            }
            if (model.DeleteResourceContentLangs != null)
            {
                await DeleteContentsOfResourceAsync(model.DeleteResourceContentLangs, entity.Id);
            }
            if (model.CategoryIds != null)
            {
                await DeleteAllCategoriesOfResourceAsync(entity);

                AddResourceCategoriesToResource(model.CategoryIds, entity);
            }
        }
コード例 #2
0
ファイル: PostService.cs プロジェクト: war-man/SmartKiosk
        protected async Task SetPostImageUrlAsync(Post entity, FileDestination image,
                                                  FileDestinationMetadata metadata)
        {
            var imageUrl = await _fileService.GetFileUrlAsync(image, metadata);

            entity.ImageUrl = imageUrl;
        }
コード例 #3
0
ファイル: PostService.cs プロジェクト: war-man/SmartKiosk
 public async Task UpdatePostTransactionAsync(Post entity,
                                              UpdatePostModel model,
                                              FileDestinationMetadata metadata = null)
 {
     if (model.Info != null)
     {
         model.Info.CopyTo(entity);
     }
     if (model.NewPostContents != null)
     {
         CreatePostContents(model.NewPostContents, entity);
     }
     if (model.UpdatePostContents != null)
     {
         UpdatePostContents(model.UpdatePostContents, entity.Id);
     }
     if (model.DeletePostContentLangs != null)
     {
         await DeleteContentsOfPostAsync(model.DeletePostContentLangs, entity.Id);
     }
     if (model.Image != null)
     {
         await SetPostImageUrlAsync(entity, model.Image, metadata);
     }
 }
コード例 #4
0
        public ResourceType CreateResourceType(CreateResourceTypeModel model,
                                               FileDestinationMetadata metadata = null)
        {
            var entity = model.ToDest();

            PrepareCreate(entity);
            return(context.ResourceType.Add(entity).Entity);
        }
コード例 #5
0
ファイル: ResourceService.cs プロジェクト: war-man/SmartKiosk
        protected async Task SetResourceLogoUrlAsync(Resource entity,
                                                     FileDestination logo,
                                                     FileDestinationMetadata metadata)
        {
            var logoUrl = await _fileService.GetFileUrlAsync(logo, metadata);

            entity.LogoUrl = logoUrl;
        }
コード例 #6
0
        public EntityCategory CreateEntityCategory(CreateEntityCategoryModel model,
                                                   FileDestinationMetadata metadata = null)
        {
            var entity = model.ToDest();

            PrepareCreate(entity);
            return(context.EntityCategory.Add(entity).Entity);
        }
コード例 #7
0
ファイル: PostService.cs プロジェクト: war-man/SmartKiosk
        public async Task <Post> CreatePostAsync(CreatePostModel model,
                                                 FileDestinationMetadata metadata = null)
        {
            var entity = model.ToDest();

            if (model.Image != null)
            {
                await SetPostImageUrlAsync(entity, model.Image, metadata);
            }
            PrepareCreate(entity);
            return(context.Post.Add(entity).Entity);
        }
コード例 #8
0
ファイル: ResourceService.cs プロジェクト: war-man/SmartKiosk
        public async Task <Resource> CreateResourceAsync(CreateResourceModel model,
                                                         FileDestinationMetadata metadata)
        {
            var entity = model.ToDest();

            if (model.Image != null)
            {
                await SetResourceImageUrlAsync(entity, model.Image, metadata);
            }
            if (model.Logo != null)
            {
                await SetResourceImageUrlAsync(entity, model.Logo, metadata);
            }
            AddResourceCategoriesToResource(model.CategoryIds, entity);
            PrepareCreate(entity);
            return(context.Resource.Add(entity).Entity);
        }
コード例 #9
0
        public async Task <IFile> GetFileAsync(FileDestination fileDest,
                                               FileDestinationMetadata metadata)
        {
            if (fileDest.RelativePath != null)
            {
                return(new FileSystemFile(metadata.RootPath + "/" + fileDest.RelativePath));
            }
            else if (fileDest.EFHash != null)
            {
                var driver   = GetFileSystemDriver(metadata.RootVolume);
                var fullPath = await driver.ParsePathAsync(fileDest.EFHash);

                var file = fullPath.File;
                return(file);
            }
            return(null);
        }
コード例 #10
0
        public async Task <string> GetFileUrlAsync(
            FileDestination fileDest,
            FileDestinationMetadata metadata)
        {
            if (fileDest.RelativePath != null)
            {
                return(metadata.SourceUrl + "/" + fileDest.RelativePath);
            }
            else if (fileDest.EFHash != null)
            {
                var driver   = GetFileSystemDriver(metadata.RootVolume);
                var fullPath = await driver.ParsePathAsync(fileDest.EFHash);

                var file    = fullPath.File;
                var relPath = file.FullName.Replace(metadata.RootPath, "")
                              .Replace("\\", "/");
                return(metadata.SourceUrl + relPath);
            }
            return(fileDest.Url);
        }