public TipoProductoDetailsDto GetDetallesPorId(int?id)
 {
     try
     {
         var tipoDetalle = _context.TipoProductos
                           .GroupJoin(_context.Productos, tp => tp.TipoProductoId, p => p.TipoProductoId,
                                      (tipo, productos) => new
         {
             Tipo      = tipo,
             Productos = productos
         })
                           .SingleOrDefault(tp => tp.Tipo.TipoProductoId == id);
         TipoProductoDetailsDto tipoDetalleDto = null;
         if (tipoDetalle != null)
         {
             //tipoDetalleDto = new TipoProductoDetailsDto
             //{
             //    Tipo = _mapper.Map<TipoProductoListDto>(tipoDetalle.Tipo),
             //    ProductosListDto = _mapper.Map<List<ProductoListDto>>(tipoDetalle.Productos.ToList())
             //};
             tipoDetalleDto                  = new TipoProductoDetailsDto();
             tipoDetalleDto.Tipo             = _mapper.Map <TipoProductoListDto>(tipoDetalle.Tipo);
             tipoDetalleDto.ProductosListDto =
                 _mapper.Map <List <ProductoListDto> >(tipoDetalle.Productos.ToList());
         }
         return(tipoDetalleDto);
     }
     catch (Exception ex)
     {
         throw new Exception("Error al intentar leer los tipos de productos");
     }
 }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TipoProductoEditDto tipoDto = _servicio.GetTipoPorId(id);

            if (tipoDto == null)
            {
                return(HttpNotFound("Código de tipo de producto inexistente..."));
            }

            TipoProductoDetailsDto tipoDetailDto = _servicio.GetDetallesPorId(id);

            TipoProductoDetailsViewModel tipoDetailVm = _mapper.Map <TipoProductoDetailsViewModel>(tipoDetailDto);

            return(View(tipoDetailVm));
        }