Ejemplo n.º 1
0
        public async Task <ResponseViewModel> CreateAsync(BlogCreateRequestViewModel request)
        {
            // Adiciona o Blog
            BlogCreateCommand blogCreateCommand = new BlogCreateCommand(request.Title, request.Description, request.Image, request.Tag, request.Url);
            ResponseCommand   responseCommand   = await _mediator.Send(blogCreateCommand, CancellationToken.None).ConfigureAwait(true);

            // Retorna
            return((!responseCommand.Success)
                ? new ResponseViewModel(false, responseCommand.Object)
                : new ResponseViewModel(true, "Blog created"));
        }
        public async Task CreateAsync(BlogCreateCommand request)
        {
            var bsonDocumentRequest = new BsonDocument(
                new Dictionary <string, string> {
                { "Guid", Guid.NewGuid().ToString() },
                { "Date", DateTime.Now.ToString("dd/MM/yyyy HH:mm") },
                { "Title", request.Title },
                { "Description", request.Description },
                { "Image", request.Image },
                { "Tag", request.Tag },
                { "Url", request.Url }
            }
                );

            await _collection.InsertOneAsync(bsonDocumentRequest).ConfigureAwait(false);
        }