private void AddTicketsToDB(List <BaseTicket> tickets, int orderId) { foreach (BaseTicket ob in tickets) { if (ob is ConcertTicket ct) { Ticket ticket = new Ticket(); PreTicket pt = ct.Ticket; ticket.EventId = pt.EventId; ticket.OrderId = orderId; for (int i = 0; i < ct.Ticket.Count; i++) { ticket.Comment = ""; ticketRepository.AddTicket(ticket); } eventRepository.LowerAvailableSeats(ct.Ticket.EventId, ct.Ticket.Count); } if (ob is DinnerTicket dt) { Ticket ticket = new Ticket(); PreTicket pt = dt.Ticket; ticket.EventId = pt.EventId; ticket.OrderId = orderId; for (int i = 0; i < dt.Ticket.Count; i++) { ticket.Comment = dt.Remarks; ticketRepository.AddTicket(ticket); } } } }
public async Task <IActionResult> AddTicket([FromBody] TicketViewModel model) { if (ModelState.IsValid) { Validator validator = new Validator(model); if (validator.IsValid) { try { int ticketId = await ticketsRepository.AddTicket(model); if (ticketId > 0) { return(Ok(ticketId)); } else { return(NotFound()); } } catch (Exception) { return(BadRequest()); } } else { return(BadRequest(validator.GetViolations().FirstOrDefault())); } } return(BadRequest()); }
// POST: api/Tickets public void Post([FromBody] Ticket ticket) { _repository.AddTicket(ticket); var _context = GlobalHost.ConnectionManager.GetHubContext <TicketHub>(); _context.Clients.All.addNewTicket(ticket); }
public IActionResult AddTicket(AddTicketRequest request) { if (request == null) { return(BadRequest(new { message = "Please check your input" })); } return(Ok(ticketRepository.AddTicket(request))); }
public IActionResult AddTicket(Ticket ticketToAdd) { var isTicketCreated = _ticketRepository.AddTicket(ticketToAdd); if (isTicketCreated) { return(Ok()); } return(Forbid()); }
public void Handle(BadStudyAccessionEvent e) { Ticket ticket = new Ticket() { Id = Guid.NewGuid(), Description = e.Message }; _ticketRepository.AddTicket(ticket); }
public int AddTicket(TicketVm ticket) { var basePrice = _tripRepository.GetPrice(ticket.TripId); var getNumberOfStops = _tripRepository.GetNumberOfStops(ticket.TripId, ticket.DepartureStationId, ticket.ArrivalStationId); var price = TripService.CalculatePrice(basePrice.BasePrice, basePrice.StopsPrice, getNumberOfStops); ticket.Price = price; return(_ticketRepository.AddTicket(ticket)); }
/// <summary> /// Adds the ticket supplied to the repository supplied in the constructor. /// </summary> /// <param name="ticket">The new ticket to add.</param> /// <returns>Returns the created ticket. /// Returns null if the ticket was not created.</returns> public Ticket AddTicket(Ticket ticket) { try { return(c_repository.AddTicket(ticket)); } catch (Exception ex) { throw; } }
public async Task <IActionResult> Create([Bind("TicketID,FilmID,CustomerID,Price,Date")] Ticket ticket) { if (ModelState.IsValid) { _ticketRepository.AddTicket(ticket); await _ticketRepository.Save(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerID"] = new SelectList(await _customerRepository.GetCustomers(), "CustomerID", "CustomerID", ticket.CustomerID); ViewData["FilmID"] = new SelectList(await _filmRepository.GetFilms(), "FilmID", "FilmID", ticket.FilmID); return(View(ticket)); }
public void AddTicket_ShouldAddTicket() { try { Ticket ticketToAdd = null; Ticket addedTicket = null; // Arrange ticketToAdd = new Ticket(); ticketToAdd.Title = "Unit Test 1 - Title"; ticketToAdd.Description = "Unit Test 1 - Description"; ticketToAdd.Priority = EntityModels.Enums.TicketPriority.Medium; // Act addedTicket = c_repository.AddTicket(ticketToAdd); // Assert Assert.AreSame(ticketToAdd, addedTicket); } catch (Exception ex) { throw; } }
public IActionResult AddTicket([FromBody] JObject data) { var moneyBet = Convert.ToDouble(data["moneyBet"]); var totalQuota = Convert.ToDouble(data["totalQuota"]); var pairIdJson = data["pairIds"]; var pairIds = pairIdJson.Select(x => (int)x).ToList(); var wasAddSuccessful = _ticketRepository.AddTicket(moneyBet, pairIds); if (wasAddSuccessful) { return(Ok()); } return(Forbid()); }
public Ticket CreateTicket(TicketForCreationDto ticketInput) { double totalOdd = 1; foreach (var match in ticketInput.SelectedMatches) { totalOdd *= match.SelectedOddValue; } var payoutTransaction = _transactionRepository.AddTransaction(Transaction.TransactionType.Payout, ticketInput.Stake); var stakeWithHandlingCost = ticketInput.Stake - ticketInput.Stake * 0.05; var possiblePayout = totalOdd * stakeWithHandlingCost; var ticket = new Ticket { TotalOdd = Math.Round(totalOdd, 2), Stake = Math.Round(ticketInput.Stake, 2), PossiblePayout = Math.Round(possiblePayout, 2), TransactionId = payoutTransaction.Id }; var createdTicket = _ticketRepository.AddTicket(ticket); _transactionRepository.UpdateTicketId(payoutTransaction, ticket.Id); if (IsWinningTicket(ticket)) { var paymentTransaction = _transactionRepository.AddTransaction(Transaction.TransactionType.Payment, ticket.PossiblePayout); _transactionRepository.UpdateTicketId(paymentTransaction, ticket.Id); } return(createdTicket); }
public ViewResult IDealPayment(IDealPaymentViewModel ideal) { HallMovieViewModel hallMovieViewModel = (HallMovieViewModel)TempData["hallMovieViewModel"]; try { if (ModelState.IsValid) { //hallMovieViewModel.order.OrderID = OrderRepo.GetMaxOrderID() + 1; bool PrintIDUnique = false; Random Random = new Random(); int PrintID = Random.Next(100000000, 999999999); if (OrderRepo.CheckPrintIDExist(PrintID) == false) { hallMovieViewModel.order.PrintID = PrintID; OrderRepo.AddOrder(hallMovieViewModel.order); hallMovieViewModel.order = OrderRepo.GetOrderOnPrintID(PrintID); } else { while (PrintIDUnique == false) { int NewPrintID = Random.Next(100000000, 999999999); if (OrderRepo.CheckPrintIDExist(NewPrintID) == false) { hallMovieViewModel.order.PrintID = NewPrintID; OrderRepo.AddOrder(hallMovieViewModel.order); PrintIDUnique = true; hallMovieViewModel.order = OrderRepo.GetOrderOnPrintID(NewPrintID); } else { PrintIDUnique = false; } } } foreach (Ticket ticket in hallMovieViewModel.TempTickets) { ticket.OrderID = hallMovieViewModel.order.OrderID; TicketRepo.AddTicket(ticket); } TempData["hallMovieViewModel"] = hallMovieViewModel; return(View("Success", hallMovieViewModel)); } else { TempData["hallMovieViewModel"] = hallMovieViewModel; return(View("IDealPayment")); } } catch (Exception a) { return(View("IDealPayment")); } }
public async Task <IActionResult> CreateTicketAsync([FromBody, SwaggerParameter(Description = "Values of the ticket to be created eg. which seat and what price", Required = true)] TicketToCreateDto ticketToCreateDto, [FromHeader(Name = "Accept"), SwaggerParameter(Description = "Media type to return eg. json or json+hateoas")] string mediaType, [FromRoute, SwaggerParameter(Description = "Id of the related movie", Required = true)] Guid movieId, [FromRoute, SwaggerParameter(Description = "Id of the related showtime", Required = true)] Guid showtimeId) { if (!await _showtimeRepository.MovieExists(movieId)) { return(NotFound()); } if (!await _ticketRepository.ShowtimeExists(showtimeId)) { return(NotFound()); } if (ticketToCreateDto.SeatId == Guid.Empty) { return(BadRequest()); //var availableSeat = await _seatRepository.GetFirstAvailableSeatByShowtimeIdAsync(showtimeId); //if (availableSeat == null) //{ // //Not sure if this is enough. Could be tested. // _logger.LogError("No available seats"); //} //ticketToCreateDto.SeatId = availableSeat.Id; } var ticket = Mapper.Map <Ticket>(ticketToCreateDto); ticket.ShowtimeId = showtimeId; ticket.Id = Guid.NewGuid(); _ticketRepository.AddTicket(ticket); if (!await _ticketRepository.SaveChangesAsync()) { _logger.LogError("Saving changes to database while creating a showtime failed"); } var ticketDto = Mapper.Map <TicketDto>(ticket); if (mediaType == "application/vnd.biob.json+hateoas") { var links = CreateLinksForTickets(ticketDto.Id, null); var linkedTicket = ticketDto.ShapeData(null) as IDictionary <string, object>; linkedTicket.Add("links", links); return(CreatedAtRoute("GetTicket", new { ticketId = ticketDto.Id }, linkedTicket)); } else { //Hmm why is dto used here when it's not in the other methods? return(CreatedAtRoute("GetTicket", new { ticketId = ticketDto.Id }, ticketDto)); } }
public ActionResult PinPayment(HallMovieViewModel HallMovieViewModel) { HallMovieViewModel hallMovieViewModel = (HallMovieViewModel)TempData["hallMovieViewModel"]; hallMovieViewModel.Saldo = HallMovieViewModel.Saldo; try { if (HallMovieViewModel.Saldo > hallMovieViewModel.order.TotalPrice) { //hallMovieViewModel.order.OrderID = OrderRepo.GetMaxOrderID() + 1; bool PrintIDUnique = false; Random Random = new Random(); int PrintID = Random.Next(100000000, 999999999); if (OrderRepo.CheckPrintIDExist(PrintID) == false) { hallMovieViewModel.order.PrintID = PrintID; OrderRepo.AddOrder(hallMovieViewModel.order); hallMovieViewModel.order = OrderRepo.GetOrderOnPrintID(PrintID); } else { while (PrintIDUnique == false) { int NewPrintID = Random.Next(100000000, 999999999); if (OrderRepo.CheckPrintIDExist(NewPrintID) == false) { hallMovieViewModel.order.PrintID = NewPrintID; OrderRepo.AddOrder(hallMovieViewModel.order); PrintIDUnique = true; hallMovieViewModel.order = OrderRepo.GetOrderOnPrintID(NewPrintID); } else { PrintIDUnique = false; } } } foreach (Ticket ticket in hallMovieViewModel.TempTickets) { ticket.OrderID = hallMovieViewModel.order.OrderID; TicketRepo.AddTicket(ticket); } TempData["hallMovieViewModel"] = hallMovieViewModel; return(new ViewAsPdf("Succes", hallMovieViewModel)); } else { ViewBag.Error = "Onvoldoende saldo"; TempData["hallMovieViewModel"] = hallMovieViewModel; return(View("Payment")); } } catch (Exception a) { return(View("Payment")); } }