public async Task <IActionResult> CommentAddOrEdit(int orderItemId, int id = 0)
        {
            var rating = await _ratingService.GetByIdAsync(id);

            if (id == 0 && rating == null)
            {
                return(View(new CommentViewModel()
                {
                    Rating = new RatingDto {
                        Id = 0
                    }
                }));
            }
            else
            {
                var orderItem = await _orderItemService.GetByIdAsync(orderItemId);

                var model = new CommentViewModel()
                {
                    Rating = _mapper.Map <RatingDto>(rating), HasComment = orderItem.HasComment, OrderItemId = orderItem.Id
                };
                return(View(model));
            }
        }
        public async Task <ObjectResult> GetById(int id)
        {
            var response = await service.GetByIdAsync(id);

            return(response.AsResource(mapper));
        }
Example #3
0
        public async Task <IActionResult> GetById(int id)
        {
            var orderItemById = await _orderItemService.GetByIdAsync(id);

            return(Ok(_mapper.Map <OrderItemDto>(orderItemById)));
        }