Example #1
0
        public async Task Create(CreateBlogInput input, string imageFolderPath)
        {
            var sources   = input.Content.GetBase64Sources();
            var extension = "";

            byte[] imageBytes = null;
            string imageName  = "";

            foreach (var src in sources)
            {
                extension  = src.GetExtensionFromBase64ImageSource();
                imageBytes = Convert.FromBase64String(src.GetValueFromBase64ImageSource());
                imageName  = $"{Guid.NewGuid()}.{extension}";
                Upload.ByteArrayToFile($"{imageFolderPath}/{imageName}", imageBytes);
                input.Content = input.Content.Replace(src, $"{_configuration.GetSection("Domain").Value}/{ContentPage.IMAGE_PATH}/{imageName}");
            }

            var blog = new Blog(
                title: input.Title,
                image: await Upload.UploadImageAsync(input.Image, imageFolderPath),
                description: input.Description,
                content: input.Content,
                seoUrl: input.SeoUrl,
                metaDescription: input.MetaDescription,
                metaTitle: input.MetaTitle);

            await _blogService.Create(blog);

            await _blogService.SaveChangesAsync();
        }
Example #2
0
        public async Task <IActionResult> Create([FromForm] CreateBlogInput input)
        {
            var absolutePath = Path.Combine(_webHostEnvironment.WebRootPath, Blog.IMAGE_PATH);

            await _blogService.Create(input, absolutePath);

            return(Ok());
        }
        public async Task <BlogDto> CreateBlog(CreateBlogInput input)
        {
            var blog = input.MapTo <Blog>();

            int id = await _blogRepository.InsertAndGetIdAsync(blog);

            blog.Id = id;

            var dto = blog.MapTo <BlogDto>();

            return(dto);
        }
Example #4
0
        public async Task Create(CreateBlogInput input)
        {
            var entity = new Blog(input.Name, AbpSession.UserId.Value);

            await _manager.Create(entity);
        }
Example #5
0
 public async Task CreateAsync(CreateBlogInput input)
 {
     var @blog = Blog.Create(AbpSession.GetTenantId(), input.Title, input.Content, input.AuthorId, input.CategoryId, input.Image);
     await _blogManager.CreateAsync(@blog);
 }