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); }
public async Task <IActionResult> GetAll() { try { return(Ok(await _postBusiness.GetAll())); } catch (Exception e) { return(Ok(e.Message)); } }