Example #1
0
        public Ticket CreateTicket(int accountId, string question)
        {
            Ticket ticketToCreate = new Ticket()
            {
                AccountId  = accountId,
                Text       = question,
                DateOpened = DateTime.Now,
                State      = TicketState.Open
            };

            return(repo.CreateTicket(ticketToCreate));
        }
Example #2
0
        public IHttpActionResult BuyTicketNoRes(TicketNoReservationCreationModel model)
        {
            NewTicketSummary summary = newTicketNoRes.New(new Ticket(model.ProjectionIdNumber, model.Row, model.Column));

            if (summary.IsCreated)
            {
                ITicketDto ticket = ticketRepo.CreateTicket(model.ProjectionIdNumber, model.Row, model.Column);

                return(Ok(ticket));
            }

            return(BadRequest(summary.Message));
        }
Example #3
0
        public void CreateTicket_WithNewTicket_AddsTicketToDb()
        {
            var t = new Ticket()
            {
                DateOpened = DateTime.Now,
                State      = TicketState.Closed,
                Text       = "Test ticket 1"
            };

            var added = _repo.CreateTicket(t);

            Assert.AreEqual(t.DateOpened, added.DateOpened);
            Assert.AreEqual(t.State, added.State);
            Assert.AreEqual(t.Text, added.Text);
        }
        // Létrehozás

        public async Task <TicketDto> CreateTicketAsync(TicketDto newTicketDto)
        {
            Ticket ticket = mapper.Map <Ticket>(newTicketDto);
            var    result = await ticketRepository.CreateTicket(ticket);

            return(mapper.Map <TicketDto>(result));
        }
Example #5
0
        public void CreateTicketWithValidTicketAddsTicketToDb()
        {
            //Arrange
            Ticket t = new Ticket()
            {
                DateOpened = DateTime.Now,
                State      = TicketState.Closed,
                Text       = "Test ticket 1"
            };

            //Act
            Ticket added = _repo.CreateTicket(t);

            //Assert
            Assert.Contains(t, _repo.ReadTickets());
            Assert.Equal(t.DateOpened, added.DateOpened);
            Assert.Equal(t.State, added.State);
            Assert.Equal(t.Text, added.Text);
        }
        public ActionResult Add(FormCollection formValues, Ticket model)
        {
            if ((formValues != null) && (formValues["Save"] != null) && (ModelState.IsValid))
            {
                _ticketRepository.CreateTicket(CurrentUserId, model);
                return(CurrentUserId == Config.MainAdminId ? RedirectToRoute("TicketIndex") : RedirectToRoute("TicketList"));
            }

            return(View());
        }
 public IActionResult Create(Ticket ticket)
 {
     //TicketListViewModel ticketListViewModel = new TicketListViewModel();
     if (ModelState.IsValid)
     {
         _ticketRepository.CreateTicket(ticket);
         return(RedirectToAction("List"));
     }
     return(View(ticket));
 }
Example #8
0
        public ActionResult <TicketReadDto> CreateTicket(TicketCreateDto ticketCreateDto)
        {
            var ticketModel = _mapper.Map <TicketModel>(ticketCreateDto);

            _ticketRepository.CreateTicket(ticketModel);
            _ticketRepository.SaveChanges();

            var ticketReadDto = _mapper.Map <TicketReadDto>(ticketModel);

            return(CreatedAtRoute(nameof(GetTicketById), new { Id = ticketReadDto.id }, ticketReadDto));
        }
        private void buyButton_Click(object sender, EventArgs e)
        {
            if (theUser != null)
            {
                if (showtimeListBox.SelectedItem != null)
                {
                    if (movieListbox.SelectedItem != null)
                    {
                        string   movie = movieListbox.SelectedItem.ToString();
                        string   full  = showtimeListBox.SelectedItem.ToString();
                        string[] array = full.Split(' ');
                        string   time  = array[0];
                        string   date  = array[14];
                        string   price = array[27];

                        IReadOnlyList <Movie>    m = movieRepo.RetrieveMovie(movie);
                        IReadOnlyList <ShowTime> s = showtimeRepo.RetrieveMovieShowTime(m[0].MovieId);

                        ShowTime current = null;
                        foreach (ShowTime show in s)
                        {
                            if (show.Date == date && show.Time == time)
                            {
                                current = show;
                                break;
                            }
                        }

                        Viewer v = viewerRepo.RetrieveViewerOnEmail(theUser.userName);

                        Ticket newTicket = ticketRepo.CreateTicket(v.ViewerId, current.ShowTimeId);

                        string ticketMessage = "Ticket for " + movie + " purchased!\n Thank you for your order!";

                        MessageBox.Show(ticketMessage);
                    }
                    else
                    {
                        MessageBox.Show("No movie selected");
                    }
                }
                else
                {
                    MessageBox.Show("No Time selected");
                }
            }
            else
            {
                MessageBox.Show("You need to be signed in to purchase a ticket.");
            }
        }
Example #10
0
        public async Task <bool> Handle(CreateTicketCommand request, CancellationToken cancellationToken)
        {
            var files = new List <File>()
            {
                new File()
                {
                    FileType = "doc", Stream = request.FileBytes, TimeStamp = DateTime.Now
                }
            };
            var ticket = new Ticket(request.Title, request.TicketNumber, null, request.Description, request.Type, request.Status, files);
            await _ticketRepository.CreateTicket(ticket);

            var result = await _unitOfWork.Save();

            return(result);
        }
        public void AddTicketWithAccountIdAndQuestionReturnsNewTicket(string question, int accountId)
        {
            _repository = Substitute.For <ITicketRepository>();
            _repository.CreateTicket(Arg.Any <Ticket>()).Returns(new Ticket
            {
                Text         = question,
                AccountId    = accountId,
                TicketNumber = 1
            });
            _mgr = new TicketManager(_repository);

            Ticket t = _mgr.AddTicket(accountId, question);

            Assert.Equal(question, t.Text);
            Assert.Equal(accountId, t.AccountId);
        }
Example #12
0
        public async Task <Ticket> CreateTicket(CreateTicketRequest createTicket)
        {
            Ticket ticket;

            try
            {
                ticket = _ticketConverter.CreateTicketRequestToTicket(createTicket);
            }
            catch
            {
                throw;
            }

            await _ticketRepository.CreateTicket(ticket);

            return(ticket);
        }
Example #13
0
        public ICommandResult Handle(CreateTicketCommand Commad)
        {
            // fail fast validations
            Commad.Validate();
            if (Commad.Invalid)
            {
                AddNotifications(Commad);
                return(new CommadResult(false, "Não foi possível realizar o seu cadastro"));
            }

            // valida o status
            if (Commad.Status != Enums.ETicketStatusType.Aberta)
            {
                AddNotification("Status", "O status inicial de um ticket não pode ser diferente de aberta");
            }


            // Gerar so VO's
            var nameClientUser  = new Name(Commad.ClientFirstName, Commad.ClientLastName);
            var emailClientUser = new Email(Commad.ClientEmail);
            var clientUser      = new ClientUser(nameClientUser,
                                                 emailClientUser,
                                                 Commad.ClientId,
                                                 Commad.ClientToken,
                                                 Commad.ClientCompany,
                                                 Commad.ClientCallNumber);

            //gerar a entidade
            var ticket = new Ticket("0009-0", Commad.Title, Commad.Description, Commad.Status, Commad.Priority, clientUser);

            // agrupar as validações
            AddNotifications(nameClientUser, emailClientUser, clientUser, ticket);

            // valida
            if (Invalid)
            {
                return(new CommadResult(false, "Erro ao salva o ticket"));
            }

            // salva o ticket
            _ticketRepsitory.CreateTicket(ticket);
            return(new CommadResult(true, "Ticket salvo com sucesso"));
        }
        public void CreateTicketWithValidTicketAddsTicketToDb()
        {
            //Arrange
            var t = new Ticket()
            {
                DateOpened = DateTime.Now,
                State      = TicketState.Closed,
                Text       = "Test ticket 1"
            };

            //Act
            var added = _repo.CreateTicket(t);

            //Assert
            Assert.AreEqual(t.DateOpened, added.DateOpened, "Dates should be equal");
            Assert.AreEqual(t.State, added.State, "States should be equal");
            Assert.AreEqual(t.Text, added.Text, "Texts should be equal");
        }
Example #15
0
        public async Task <IActionResult> CreateTicket(TicketCreateDTO ticketDTO)
        {
            var validatedTitle       = ticketDTO.Title.ToLower();
            var validatedDescription = ticketDTO.Description.ToLower();
            var validatedWebsiteUrl  = ticketDTO.WebsiteUrl.ToLower();

            // new ticket schema
            var ticketToCreate = new Ticket
            {
                Title       = validatedTitle,
                Description = validatedDescription,
                WebsiteUrl  = validatedWebsiteUrl,
                Priority    = ticketDTO.Priority,
                // CreatedDate = DateTime.Now()
            };

            var createdUser = await _repo.CreateTicket(ticketToCreate);

            // return CreatedAtRoute()
            return(StatusCode(201));
        }
        public async Task <IActionResult> CreateTicket([FromBody] Ticket ticket)
        {
            if (!(await IsUserLogged()))
            {
                return(Unauthorized("You need to login"));
            }

            ticket.SelectedNum = String.Concat(ticket.SelectedNum.Where(c => !Char.IsWhiteSpace(c)));

            if (!ticketValidation.IsValidSelectedNumbers(ticket.SelectedNum))
            {
                return(BadRequest("Selected numbers are not valid"));
            }

            if (!ticketValidation.IsValidStake(ticket.Stake))
            {
                return(BadRequest("You stake value is not valid"));
            }

            int userId = GetUserFromCookie();

            if (!(await ticketValidation.IsPossibleBetting(ticket.Stake, userId)))
            {
                return(BadRequest("Insufficient Funds"));
            }

            ticket.IdUser = userId;
            var newTicket = await ticketRepository.CreateTicket(ticket);

            if (newTicket == null)
            {
                return(BadRequest("Ticket is invalid"));
            }


            return(Ok(newTicket));
        }
Example #17
0
        public Ticket CreateTicket(int reservationId, string fName, string lName)
        {
            var res = _resRepo.Get(reservationId);

            if (res.TicketId != null)
            {
                throw new InvalidOperationException("ticket has been already issued to this reservation, unable to create another one");
            }

            var placeInRun = _matchRepo.GetPlaceAtMatch(res.PlaceAtMatchId);

            var newTicket = new Ticket()
            {
                ReservationId   = res.Id,
                FirstName       = fName,
                LastName        = lName,
                PriceComponents = new List <PriceComponent>()
            };

            newTicket.PriceComponents = _priceCalculationStrategy.CalculatePrice(placeInRun);

            _tickRepo.CreateTicket(newTicket);
            return(newTicket);
        }
Example #18
0
        public int CreateTicket(TicketCreateVM ticket)
        {
            var dto = mapper.ConvertTo <TicketCreateDTO>(ticket);

            return(ticketRepository.CreateTicket(dto));
        }
        public ActionResult Create()
        {
            var ticket = _ticketRepository.CreateTicket();

            return(View(ticket));
        }
 private Ticket AddTicket(Ticket ticket)
 {
     this.Validate(ticket);
     return(repo.CreateTicket(ticket));
 }
        public Guid RegistrateUser(string nickname, string password)
        {
            string hash = _cryptoProvider.GetMd5Hash(password);

            return(_repository.CreateTicket(nickname, hash));
        }