public async Task <IActionResult> Create([Bind("Id,SeatNumber,MovieId,UserId,StartTime,Status")] Transaction transaction) { if (ModelState.IsValid) { await Task.Run(() => _transactionRepository.CreateTransaction(transaction)); return(RedirectToAction(nameof(Index))); } return(View(transaction)); }
public async Task <IActionResult> RegisterSeats(string seats) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } var user = await _userManager.GetUserAsync(User); var json = JObject.Parse(seats); var transaction = new Transaction { MovieId = json["movieId"].ToObject <int>(), SeatNumber = string.Join(",", json["seats"].ToObject <List <int> >().ToArray()), StartTime = DateTime.Now, Status = TransactionStatus.InProcess, UserId = user.Id, Price = TicketPrice * json["seats"].ToObject <List <int> >().Count }; return(Json(await Task.Run(() => _transactionRepository.RegisterSeats(transaction)))); }