public async Task <ActionResult> BookNow(Booking vm) { int Id = Convert.ToInt32(TempData["MovieId"]); string c = "no"; List <Booking> bookings = new List <Booking>(); HttpClient client = _api.Initalbookingt(); HttpResponseMessage ress = await client.GetAsync("api/Bookingt"); if (ress.IsSuccessStatusCode) { var results = ress.Content.ReadAsStringAsync().Result; bookings = JsonConvert.DeserializeObject <List <Booking> >(results); foreach (var item in bookings) { if (item.seatno == vm.seatno && item.MovieDetailsId == Id) { c = "yes"; break; } else { c = "no"; } } } if (c == "yes") { ViewBag.msg = "This seat is already booked go for another"; } else { Booking vmm = new Booking(); string UserN = TempData["username"].ToString(); vmm.MovieDetailsId = Id; vmm.UserName = UserN; vmm.seatno = vm.seatno; List <MovieData> movies = new List <MovieData>(); HttpClient clientttt = _api.Initalmovie(); HttpResponseMessage res = await clientttt.GetAsync("api/Movie"); if (res.IsSuccessStatusCode) { var results = res.Content.ReadAsStringAsync().Result; movies = JsonConvert.DeserializeObject <List <MovieData> >(results); } foreach (var itemm in movies) { if (itemm.Id == Id) { vmm.Datetopresent = itemm.DateAndTime; vmm.MovieName = itemm.Movie_Name; break; } } HttpClient clientt = _api.Initalbookingt(); var postTask = clientt.PostAsJsonAsync <Booking>($"api/Bookingt", vmm); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { TempData.Keep(); return(RedirectToAction("cart")); } } return(View()); }