Example #1
0
        public async Task <IActionResult> MakeBid(MakeBidViewModel makeBidViewModel)
        {
            if (!User.Identity.IsAuthenticated)
            {
                // Get the previous page URL.
                var prevUri = Request.Headers["Referer"].ToString();
                var start   = prevUri.IndexOf("Lot") - 1;
                var res     = prevUri.Substring(start, (prevUri.Length - start));
                return(RedirectToAction("LogIn", "Account", new { returnUrl = res }));
            }

            var bid = _maper.Map <MakeBidViewModel, Bid>(makeBidViewModel);

            bid.AppUserID = User.FindFirstValue(ClaimTypes.NameIdentifier);
            bid.BidTime   = DateTime.Now;
            var result = await _bidService.CreateBidAsync(bid);

            if (!result.Succeeded)
            {
                TempData["Error"] = result.Error;
            }

            return(RedirectToAction("Details", new { id = makeBidViewModel.LotID }));
        }