Exemplo n.º 1
0
        public async Task <SaleViewModel> ItemAsync(int?id)
        {
            var user   = HttpContext.User;
            var test   = _userManager.GetUserAsync(User);
            var testId = _userManager.GetUserId(User);

            var test1 = id != null ? await _catalogService.LoadByIdAsync(id.Value) : throw new Exception(nameof(id));

            SaleViewModel saleItem = new SaleViewModel
            {
                Id             = test1.Id,
                Name           = test1.Name,
                PriceAfterSale = test1.PriceAfterSale.ToString("C0"),
                OriginPrice    = test1.OriginPrice.ToString("C0"),
                Image          = test1.Image,
                ValidFrom      = test1.ValidFrom,
                ValidTo        = test1.ValidTo,
                LinkFirm       = test1.LinkFirm,
                Description    = test1.Description,
                PercentSale    = (int)test1.PercentSale,
                DateInsert     = _helpService.TimeAgo(test1.DateInsert),
                RankSale       = test1.RankSale,
                CategoryName   = test1.Category?.Name ?? "Ostatní",
                CategoryId     = test1.Category?.Id ?? 5
            };

            return(saleItem);
        }