public int UpdatePost(PostDC postDC, List <CategoryDC> categoryListDC) { try { List <CategoryDto> categoryDtoList = new List <CategoryDto>(); foreach (CategoryDC categoryDC in categoryListDC) { categoryDtoList.Add(new CategoryDto { Id = categoryDC.Id, CategoryName = categoryDC.CategoryName }); } return(PostService.UpdatePost(new PostDto { Id = postDC.Id, Title = postDC.Title, Body = postDC.Body, PostImage = postDC.PostImage }, categoryDtoList)); } catch (ApplicationException ex) { throw new FaultException(ex.Message); } }
public int DeletePost(PostDC postDC) { try { return(PostService.DeletePost(new PostDto { Id = postDC.Id })); } catch (ApplicationException ex) { throw new FaultException(ex.Message); } }
public PostViewModel GetPost(int postId) { try { PostDC postDC = PostServiceClient.GetPost(postId); return(new PostViewModel { Id = postDC.Id, Title = postDC.Title, Body = postDC.Body, CreationDate = postDC.CreationDate.ToString(), PostImage = postDC.PostImage }); } catch (FaultException ex) { throw new ApplicationException(ex.Message); } }