public IActionResult AddBid(Bids newbid) { int show_id = newbid.auction_id; ViewBag.User_one = userFactory.CurrentUser((int)HttpContext.Session.GetInt32("current_id")); List <string> temp_errors = new List <string>(); //Checking bids table if entry present remove that entry new one ViewBag.Switch = bidFactory.Switch(newbid.auction_id, newbid.user_id); if (ModelState.IsValid) { if (newbid.bid_amount < ViewBag.User_one.wallet && newbid.bid_amount > newbid.top_bid) { if (ViewBag.Switch == 1) { bidFactory.Leave_Bid(newbid.auction_id, newbid.user_id); bidFactory.Join_Bid(newbid); return(RedirectToAction("Dashboard")); } else { bidFactory.Join_Bid(newbid); return(RedirectToAction("Dashboard")); } } else { temp_errors.Add("Change your bid amount"); TempData["errors"] = temp_errors; return(RedirectToAction("Show", new { id = show_id })); } } foreach (var error in ModelState.Values) { if (error.Errors.Count > 0) { temp_errors.Add(error.Errors[0].ErrorMessage); } } TempData["errors"] = temp_errors; return(RedirectToAction("Dashboard")); }