/// <summary> /// Gets the specified author. /// </summary> /// <param name="request">The request.</param> /// <returns> /// <c>GetAuthorRequest</c> with an author. /// </returns> public GetAuthorResponse Get(GetAuthorRequest request) { var query = repository.AsQueryable<Module.Blog.Models.Author>(); query = query.Where(author => author.Id == request.AuthorId); var model = query .Select(author => new AuthorModel { Id = author.Id, Version = author.Version, CreatedBy = author.CreatedByUser, CreatedOn = author.CreatedOn, LastModifiedBy = author.ModifiedByUser, LastModifiedOn = author.ModifiedOn, Name = author.Name, ImageId = author.Image != null && !author.Image.IsDeleted ? author.Image.Id : (Guid?)null, ImageUrl = author.Image != null && !author.Image.IsDeleted ? author.Image.PublicUrl : (string)null, ImageThumbnailUrl = author.Image != null && !author.Image.IsDeleted ? author.Image.PublicThumbnailUrl : (string)null, ImageCaption = author.Image != null && !author.Image.IsDeleted ? author.Image.Caption : (string)null }) .FirstOne(); model.ImageUrl = fileUrlResolver.EnsureFullPathUrl(model.ImageUrl); model.ImageThumbnailUrl = fileUrlResolver.EnsureFullPathUrl(model.ImageThumbnailUrl); return new GetAuthorResponse { Data = model }; }
GetBookByAuthorIdAsync(GetAuthorRequest request) { if (request?.Id == null) { throw new ArgumentNullException(); } var result = await _itemRepository.GetBookByAuthorIdAsync(request.Id); return(result.Select(_itemMapper.Map)); }
public async Task <AuthorResponse> GetAuthorAsync(GetAuthorRequest request) { if (request?.Id == null) { throw new ArgumentNullException(); } var result = await _artistRepository.GetAsync(request.Id); return(result == null ? null : _artistMapper.Map(result)); }
public async Task <IActionResult> GetAuthor([FromBody] GetAuthorRequest request) { if (request == null) { return(NotFound()); } Author author = await _authorService.GetById(request.Id); ListAuthorResponse response = new ListAuthorResponse(); response.Id = author.Id; response.Name = author.Name; return(Ok(response)); }
public override async Task <GetAuthorResponse> GetAuthor(GetAuthorRequest request, ServerCallContext context) { var author = await _authorDbContext.Authors .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == request.AuthorId); if (author != null) { return(new GetAuthorResponse { AuthorId = author.Id, AuthorName = author.Name }); } return(new GetAuthorResponse()); }
public IHttpActionResult Get(int id) { var loggedUserId = HttpContext.Current.GetOwinContext().GetUserId(); var request = new GetAuthorRequest() { RequestToken = Guid.NewGuid(), UserId = loggedUserId, Id = id }; var authorsResponse = _authorService.GetAuthor(request); if (!authorsResponse.Success) { return(BadRequest(authorsResponse.Message)); } return(Ok(authorsResponse.Author.MapToViewModel())); }
public GetAuthorResponse GetAuthor(GetAuthorRequest request) { var response = new GetAuthorResponse() { Request = request, ResponseToken = Guid.NewGuid() }; try { response.Author = _repository.FindBy(request.Id).MapToView(); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } return(response); }