public async Task <FileResultDto> CreateAsync(CreateFileDto model) { var file = await _factory.MakeAsync(model); await _repository.AddAndSaveAsync(file); return(await Task.FromResult( file.Adapt <FileResultDto>() )); }
public async Task <AdminSliderResultDto> CreateAsync(AdminCreateSliderDto model) { model.CheckArgumentIsNull(nameof(model)); var post = await _postFactory.MakeSliderPostAsync( title : model.Title, slug : model.Slug, langId : model.LangId, enabled : model.Enabled); foreach (var item in model.Items) { var file = await _fileFactory.MakeAsync(item); var postFile = await _postFileFactory.MakeAsync( file, title : item.Title, postId : null, relatedFileId : null, item.OrderNum); post.PostFiles.Add(postFile); } await _postRepository.AddAndSaveAsync(post); var result = new AdminSliderResultDto { Enabled = model.Enabled, LangId = model.LangId, PostId = post.Id, Slug = post.Slug, Title = post.Title }; var items = new List <AdminSliderResultItemDto>(); foreach (var file in post.PostFiles) { items.Add(new AdminSliderResultItemDto { FileId = file.FileId, FilePath = file.File.FilePath, OrderNum = file.OrderNum, PostFileId = file.Id, Title = file.Title, Url = file.File.Url }); } result.Items = items; return(result); }