public ActionResult BuyTicket(long id) { Ticket ticket = new TicketBuilder() .SetEventId(id) .Build(); if (TempData["user"] != null) { var userJson = JsonConvert.DeserializeObject(TempData["user"].ToString()); JToken token = JObject.Parse(userJson.ToString()); ticket.SetUserId((long)token.SelectToken("Id")); User user = new UserBuilder() .SetId((long)token.SelectToken("Id")) .SetUsername((string)token.SelectToken("Username")) .Build(); TempData["user"] = JsonConvert.SerializeObject(user); } if (ticket.GetUserId() == 0) { return(StatusCode(404)); } ticketService.CreateTicket(ticket); return(RedirectToAction("UserTickets")); }