public async Task <ActionResult <EntityList <BookTypeViewModel> > > GetAll( [FromQuery] string name, [FromQuery] int page, [FromQuery] int pageSize) { var types = await _typeService.GetAsync(name, page, pageSize); return(Ok(types));; }
public async Task <ActionResult <BookViewModel> > Get( [FromQuery(Name = "id")] string id ) { var book = await _bookService.GetAsync(id); if (book == null) { return(BadRequest("book not found")); } var type = await _typeService.GetAsync(book.TypeId); var publishingHouse = await _publishingHouseService.GetAsync(book.PublishHouseId); var author = await _authorService.GetAsync(book.AuthorId, Request); var tag = await _tagService.GetAsync(book.TagId); BookViewModel bookViewModel = new BookViewModel() { Id = book.Id, BookName = book.BookName, Description = book.Description, Price = book.Price.ToString(), CoverPrice = book.CoverPrice.ToString(), ImgUrl = book.ImgUrl, Rating = Rouding.Adjust(Average.CountingAverage(book.Comments)), BookTypeName = type.Name, PublishingHouseName = publishingHouse.Name, Cover_Type = book.CoverType, PageAmount = book.PageAmount, PublishDate = Convert.ToDateTime(book.PublishDate).ToString("yyyy-MM-dd"), Size = book.Size, AuthorName = author.Name, AuthorId = author.Id, PublishingHouseId = publishingHouse.Id, TypeId = type.Id, TagId = book.TagId, TagName = tag.Name, Amount = book.Amount, ZoneType = book.ZoneType }; return(Ok(bookViewModel)); }