public IActionResult AddAuction(Auction newauction) { List <string> temp_errors = new List <string>(); if (ModelState.IsValid) { if (newauction.bidend_date > DateTime.Now && newauction.start_bid > 0) { bidFactory.AddAuction(newauction); ViewBag.User_Extracting = bidFactory.Auction_Last_ID(); bidFactory.Add_Bider(ViewBag.User_Extracting.id, (int)HttpContext.Session.GetInt32("current_id"), newauction.start_bid); Console.WriteLine("Auction is Successfully added"); return(RedirectToAction("Dashboard")); } else { temp_errors.Add("Select Bid End date and Price of Bid correctly"); TempData["errors"] = temp_errors; return(RedirectToAction("New")); } } foreach (var error in ModelState.Values) { if (error.Errors.Count > 0) { temp_errors.Add(error.Errors[0].ErrorMessage); } } TempData["errors"] = temp_errors; return(RedirectToAction("New")); }