예제 #1
0
        public void ReadTicketResponsesOfTicketWithIdOneReturnsAListOfTicketResponses()
        {
            //Arrange
            Ticket testTicket = new Ticket
            {
                Text       = "Test ticket",
                AccountId  = 1,
                DateOpened = DateTime.Now,
                State      = TicketState.Closed,
            };

            TicketResponse tr = new TicketResponse
            {
                Date             = DateTime.Today.AddDays(1),
                IsClientResponse = false,
                Text             = "Answer 1",
                Ticket           = testTicket,
            };
            var id = _repo.CreateTicket(testTicket).TicketNumber;

            _repo.CreateTicketResponse(tr);

            //Act
            List <TicketResponse> result = _repo.ReadTicketResponsesOfTicket(id).ToList();

            //Assert
            Assert.Contains(tr, result);
        }
예제 #2
0
        public TicketResponse AddTicketResponse(int ticketNumber, string response, bool isClientResponse)
        {
            Ticket ticketToAddResponseTo = repo.ReadTicket(ticketNumber);
            //ticketToAddResponseTo.Responses = new List<TicketResponse>();
            TicketResponse newTicketResponse = new TicketResponse();

            newTicketResponse.Date             = DateTime.Now;
            newTicketResponse.Text             = response;
            newTicketResponse.IsClientResponse = isClientResponse;
            newTicketResponse.Ticket           = ticketToAddResponseTo;
            repo.CreateTicketResponse(newTicketResponse);
            return(newTicketResponse);
        }
        public TicketResponse AddTicketResponse(int ticketNumber, string response, bool isClientResponse)
        {
            Ticket ticketToAddResponseTo = this.GetTicket(ticketNumber);

            if (ticketToAddResponseTo != null)
            {
                // Create response
                TicketResponse newTicketResponse = new TicketResponse();
                newTicketResponse.Date             = DateTime.Now;
                newTicketResponse.Text             = response;
                newTicketResponse.IsClientResponse = isClientResponse;
                newTicketResponse.Ticket           = ticketToAddResponseTo;

                // Add response to ticket
                var responses = this.GetTicketResponses(ticketNumber);
                if (responses != null)
                {
                    ticketToAddResponseTo.Responses = responses.ToList();
                }
                else
                {
                    ticketToAddResponseTo.Responses = new List <TicketResponse>();
                }
                ticketToAddResponseTo.Responses.Add(newTicketResponse);

                // Change state of ticket
                if (isClientResponse)
                {
                    ticketToAddResponseTo.State = TicketState.ClientAnswer;
                }
                else
                {
                    ticketToAddResponseTo.State = TicketState.Answered;
                }


                // Validatie van ticketResponse en ticket afdwingen!!!
                this.Validate(newTicketResponse);
                this.Validate(ticketToAddResponseTo);

                // Bewaren naar db
                repo.CreateTicketResponse(newTicketResponse);
                repo.UpdateTicket(ticketToAddResponseTo);

                return(newTicketResponse);
            }
            else
            {
                throw new ArgumentException("Ticketnumber '" + ticketNumber + "' not found!");
            }
        }
예제 #4
0
        public TicketResponse AddTicketResponse(int ticketNumber, string response, bool isClientResponse)
        {
            Ticket ticketToAddResponseTo = GetTicket(ticketNumber);

            if (ticketToAddResponseTo != null)
            {
                //Create new response
                TicketResponse newResponse = new TicketResponse()
                {
                    Date             = DateTime.Now,
                    Text             = response,
                    IsClientResponse = isClientResponse,
                    Ticket           = ticketToAddResponseTo
                };

                //add response to ticket
                var responses = GetTicketResponses(ticketNumber);

                if (response != null)
                {
                    ticketToAddResponseTo.Responses = responses.ToList();
                }
                else
                {
                    ticketToAddResponseTo.Responses = new List <TicketResponse>();
                }

                ticketToAddResponseTo.Responses.Add(newResponse);

                //change state of ticket

                if (isClientResponse)
                {
                    ticketToAddResponseTo.State = TicketState.ClientAnswer;
                }
                else
                {
                    ticketToAddResponseTo.State = TicketState.Answered;
                }

                //Save changes to repository
                repo.CreateTicketResponse(newResponse);
                repo.UpdateTicket(ticketToAddResponseTo);

                return(newResponse);
            }
            else
            {
                throw new ArgumentException("Ticketnumber '" + ticketNumber + "' not found!");
            }
        }