public async Task <GetBlogOutput> GetBlogAsync(GetBlogInput input) { if (input.Id == 0) { throw new UserFriendlyException("خطا در دریافت اطلاعات"); } var pc = _blogRepo.GetAll() .SingleOrDefault(p => p.Id == input.Id); if (pc == null) { throw new UserFriendlyException("آیتم مورد نظر وجود ندارد ویا حذف شده است !!!"); } return(new GetBlogOutput() { PC = new BlogDto() { Title = pc.Title, Id = pc.Id, CreationTime = pc.CreationTime.ToString(), Description = pc.Description, EnDescription = pc.EnDescription, EnTitle = pc.EnTitle, Labels = pc.Labels } }); }
public async Task <BlogDto> GetBlog(GetBlogInput input) { var blog = await _blogRepository.GetAllIncluding(x => x.Posts) .Where(x => x.Id == input.Id.Value) .SingleAsync(); var dto = blog.MapTo <BlogDto>(); return(dto); }
public async Task <GetBlogOutput> GetById(GetBlogInput input) { var entity = await _manager.GetById(input.Id); if (entity == null) { throw new UserFriendlyException($"Blog {input.Id} not found"); } return(ObjectMapper.Map <GetBlogOutput>(entity)); }