Ejemplo n.º 1
0
        public async Task <IActionResult> GetPostForComboBox()
        {
            var query  = new GetPostForComboBoxQuery();
            var result = await _mediator.Send(query);

            return(result != null ? new ObjectResult(result) : null);
        }
        public async Task <IEnumerable <PostForComboboxDTO> > Handle(GetPostForComboBoxQuery request, CancellationToken cancellationToken)
        {
            string functionName = "GetPostForComboBox:Get:";

            Log.ForContext("Message", functionName)
            .ForContext("Error", "")
            .Information(functionName);
            List <PostForComboboxDTO> listPost = new List <PostForComboboxDTO>();
            var posts = await _read.GetAllPost();

            foreach (var post in posts)
            {
                listPost.Add(new PostForComboboxDTO()
                {
                    Id   = post.Id,
                    Post = post.Title
                });
            }

            return(listPost);
        }