Esempio n. 1
0
        private ApiResponse <IEnumerable <PostViewModel> > GetPosts()
        {
            var apiResp = new ApiResponse <IEnumerable <PostViewModel> >
            {
                ResponseCode = ResponseCode.Fail
            };

            var resp = _postBusiness.GetAll();

            if (resp.ResponseCode != ResponseCode.Success)
            {
                apiResp.ResponseMessage = resp.ResponseMessage;

                return(apiResp);
            }

            apiResp.ResponseData = resp.ResponseData.Select(p => new PostViewModel
            {
                Id        = p.Id,
                BlogId    = p.BlogId,
                Content   = p.Content,
                CreatedAt = p.CreatedAt,
                Title     = p.Title
            });

            apiResp.ResponseCode = ResponseCode.Success;
            return(apiResp);
        }
Esempio n. 2
0
 public async Task <IActionResult> GetAll()
 {
     try
     {
         return(Ok(await _postBusiness.GetAll()));
     }
     catch (Exception e)
     {
         return(Ok(e.Message));
     }
 }