Пример #1
0
        public TiketModel CreateTicket(TiketModel ticket)
        {
            var tic = _mapper.Map <Ticket>(ticket);

            _ticketRepository.CreateTicket(tic);
            return(ticket);
        }
        public async Task <IActionResult> AddTicket([FromBody] TicketsViewModel ticketViewModel)
        {
            var callerId = GetCallerId();

            if (string.IsNullOrEmpty(callerId))
            {
                return(new BadRequestObjectResult(new
                {
                    Message = "You must be logged in to report!"
                }));
            }
            var result = await _ticketsRepository.CreateTicket(
                MapTicketViewModelIntoDataObject(ticketViewModel, callerId),
                callerId);

            return(new OkObjectResult(new
            {
                Message = "Report added1",
                result
            }));
        }
Пример #3
0
        public async Task <TicketBlModelResponse> CreateTicket(TicketBlModelRequest ticket)
        {
            TicketDalDtoModelRequest ticketRequest = new TicketDalDtoModelRequest
                                                     (
                ticket.UserId,
                ticket.PriceId
                                                     );

            CreateTicketResponseBlModel response = Mapper.Map <CreateTicketResponseBlModel>(await _ticketsRepository.CreateTicket(ticketRequest));

            if (response.Result == StoredProcedureExecutionResult.Ok)
            {
                if (ticket.Services != null)
                {
                    foreach (ServiceBlModelRequestForTicket service in ticket.Services)
                    {
                        _ticketsRepository.AddServiceToTicket(new ServiceDalDtoModelRequestForTicket(response.TicketId, service.Id, service.Amount));
                    }
                }
                return(await GetTicketById(response.TicketId));
            }
            else
            {
                return(null);
            }
        }