コード例 #1
0
        public Task <HttpResponseMessage> UpdateTicketAsync(Guid id, [FromBody] TicketWM ticketWM)
        {
            var context = _htmlResponseBuilder.CreateContext(Request);

            var response = _htmlResponseBuilder.Build(Request, () => _ticketHandler.HandlePut(id, ticketWM, context), context);

            return(Task.FromResult(response));
        }
コード例 #2
0
        public Task <HttpResponseMessage> CreateTicketAsync([FromBody] TicketWM ticketWM)
        {
            var context = _htmlResponseBuilder.CreateContext(Request);

            var response = _htmlResponseBuilder.Build(Request, () => _ticketHandler.HandlePost(context, ticketWM), context);

            response.StatusCode = response.IsSuccessStatusCode
                 ? HttpStatusCode.Created
                 : response.StatusCode;

            return(Task.FromResult(response));
        }
コード例 #3
0
        public ResponseEnvelope <TicketWM> HandlePut(Guid id, TicketWM ticketWM, ITestApiContext context)
        {
            var ticket = _objectFactory.Create <Ticket>(ticketWM);

            _ticketService.UpdateTicket(ticket);

            var updatedTicket = _ticketService.GetTicket(id);


            var ticketWMUpadted = _objectFactory.Create <TicketWM>(updatedTicket);

            var recordCounts = CreateRecordCounts(1);

            var searchResults = new ApiSearchResult <TicketWM>(recordCounts, ticketWMUpadted);

            return(_responseBuilder.CreateResponse(context, searchResults));
        }
コード例 #4
0
        public ResponseEnvelope <TicketWM> HandlePost(ITestApiContext context, TicketWM ticketWM)
        {
            var ticket = _objectFactory.Create <Ticket>(ticketWM);

            ticket.ID     = Guid.NewGuid();
            ticket.UserID = context.AuthenticatedUser.Id;
            _ticketService.AddTicket(ticket);

            var addedTicket = _ticketService.GetTicket(ticket.ID);


            var ticketWMAdded = _objectFactory.Create <TicketWM>(ticket);

            var recordCounts = CreateRecordCounts(1);

            var searchResults = new ApiSearchResult <TicketWM>(recordCounts, ticketWMAdded);

            return(_responseBuilder.CreateResponse(context, searchResults));
        }
コード例 #5
0
        private static Ticket TranslateToTicket(TicketWM ticketWM)
        {
            var ticket = Translate.From(ticketWM).To <Ticket>();

            return(ticket);
        }