public async Task <IActionResult> Edit(int id)
        {
            var userId = this.userManager.GetUserId(User);

            var loggedUserId = this.userManager.GetUserId(User);

            var currentAuction = await this.auctionService.GetAuctionByIdAsync(id, userId);

            if (currentAuction == null)
            {
                return(NotFound());
            }

            if (currentAuction.OwnerId != loggedUserId)
            {
                return(BadRequest("You are not owner/administrator of this auction!"));
            }

            var product = await this.productService.GetProductByNameAsync(currentAuction.ProductName);

            var model = new AuctionEditViewModel()
            {
                Id          = currentAuction.Id,
                ProductName = currentAuction.ProductName,
                Description = currentAuction.Description,
                //CategoryName = currentAuction.CategoryName,
                Price     = currentAuction.Price,
                ProductId = product.Id
            };

            return(View(model));
        }
        public async Task <IActionResult> Edit(AuctionEditViewModel model)
        {
            //if (!ModelState.IsValid)
            //{
            //    return View(auctionToEdit);
            //}
            var userId = this.userManager.GetUserId(User);

            var auction = await this.auctionService.GetAuctionByIdAsync(model.Id, userId);

            User loggedUser = await this.userManager.FindByNameAsync(this.User.Identity.Name);

            if (model.Description.Length < DataConstants.AuctionNameMinLength ||
                model.Description.Length > DataConstants.AuctionNameMaxLength)
            {
                return(BadRequest("Incorrect input length!"));
            }

            //var categoryForAuction = this.categoryService.GetCategoryByName(auction.CategoryName);

            //if (categoryForAuction == null)
            //{
            //    return this.BadRequest();
            //}

            if (auction.ProductId == 0)
            {
                RedirectToAction(nameof(ProductController.List), "Product");
            }

            if (auction.OwnerId != loggedUser.Id)
            {
                return(Forbid());
            }

            if (!IsValid(auction))
            {
                return(this.BadRequest());
            }

            await this.auctionService.Edit(
                auction.Id,
                model.ProductName,
                model.Description,
                auction.CategoryName,
                auction.ProductId
                );

            return(RedirectToAction(string.Concat(nameof(AuctionController.Details), "/", model.Id), "Auction"));
        }