Пример #1
0
        public async Task <IActionResult> UpdateTicket([FromQuery] int id, TicketUpdateDto newTicket)
        {
            var ticketToUpdate = await _service.GetTicketAsync(id);

            _mapper.Map(newTicket, ticketToUpdate);
            await _service.UpdateTicket(ticketToUpdate);

            return(Ok());
        }
Пример #2
0
        public async Task <Response <bool> > UpdateTicketAsync(TicketUpdateDto Ticket)
        {
            Response <Ticket> TicketUpdate = await GetTicketAsync(Ticket.Id).ConfigureAwait(false);

            TicketUpdate.Data.Usuario            = Ticket.Usuario;
            TicketUpdate.Data.Estatus            = Ticket.Estatus;
            TicketUpdate.Data.FechaActualizacion = DateTime.Now;
            await _unitOfWork.TicketRepositoryAsync.Update(TicketUpdate.Data);

            await _unitOfWork.CommitAsync();

            return(new Response <bool>(TicketUpdate != null)
            {
                Succeeded = true, Message = $"El Ticket No.{TicketUpdate.Data.Id} actualizado"
            });
        }
Пример #3
0
        public ActionResult UpdateTicket(int id, TicketUpdateDto ticketUpdateDto)
        {
            var ticketModelFromRepository = _ticketRepository.GetTicketById(id);

            if (ticketModelFromRepository == null)
            {
                return(NotFound());
            }

            _mapper.Map(ticketUpdateDto, ticketModelFromRepository);

            _ticketRepository.UpdateTicket(ticketModelFromRepository);

            _ticketRepository.SaveChanges();

            return(NoContent());
        }
Пример #4
0
        public async Task <ActionResult> DeleteTicketAsync(int id)
        {
            var ticket = await _ticketService.GetTicketByIdAsync(id);

            if (ticket == null)
            {
                return(NotFound());
            }

            // Update seat
            TicketUpdateDto ticketUpdateDto = new TicketUpdateDto();

            ticketUpdateDto.TrangThai = false;
            _mapper.Map(ticketUpdateDto, ticket);

            await _ticketService.UpdateTicketAsync(ticket);

            return(NoContent());
        }
Пример #5
0
        public async Task <IActionResult> UpdateTicket(int id, [FromBody] TicketUpdateDto ticketUpdate)
        {
            Ticket ticket = await _repo.GetTicket(id);

            if (ticket == null)
            {
                return(NotFound());
            }

            if (!string.IsNullOrEmpty(ticketUpdate.Description) || !string.IsNullOrWhiteSpace(ticketUpdate.Description))
            {
                ticket.Description = ticketUpdate.Description;
            }

            if (!string.IsNullOrEmpty(ticketUpdate.Details) || !string.IsNullOrWhiteSpace(ticketUpdate.Details))
            {
                ticket.Details = ticketUpdate.Details;
            }

            if (ticketUpdate.AssignedToId > 0)
            {
                User user = await _userRepo.GetUser(ticketUpdate.AssignedToId);

                if (user == null)
                {
                    return(BadRequest(new { error = "User not found" }));
                }

                ticket.AssignedTo = user;
            }

            if (ticketUpdate.TicketStatusId > 0)
            {
                TicketStatus status = await _repo.GetTicketStatus(ticketUpdate.TicketStatusId);

                if (status == null)
                {
                    return(BadRequest(new { error = "status not found" }));
                }

                ticket.TicketStatus = status;
            }


            if (ticketUpdate.TicketPriorityId > 0)
            {
                TicketPriority priority = await _repo.GetTicketPriority(ticketUpdate.TicketPriorityId);

                if (priority == null)
                {
                    return(BadRequest(new { error = "priority not found" }));
                }

                ticket.TicketPriority = priority;
            }

            if (ticketUpdate.TicketTypeId > 0)
            {
                TicketType type = await _repo.GetTicketType(ticketUpdate.TicketTypeId);

                if (type == null)
                {
                    return(BadRequest(new { error = "Ticket Type not found" }));
                }

                ticket.TicketType = type;
            }

            if (ticketUpdate.TicketQueueId > 0)
            {
                TicketQueue queue = await _repo.GetTicketQueue(ticketUpdate.TicketQueueId);

                if (queue == null)
                {
                    return(BadRequest(new { error = "Ticket Queue not found" }));
                }

                ticket.TicketQueue = queue;
            }

            if (ticketUpdate.ClientId > 0)
            {
                Client client = await _clientRepo.GetClient(ticketUpdate.ClientId);

                if (client == null)
                {
                    return(BadRequest(new { error = "Ticket Client not found" }));
                }

                ticket.Client = client;
            }

            if (ticketUpdate.ConfigItemId > 0)
            {
                ConfigItem item = await _clientRepo.GetConfigItem(ticketUpdate.ConfigItemId);

                if (item == null)
                {
                    return(BadRequest(new { error = "Ticket Config Item not found" }));
                }

                ticket.ConfigItem = item;
            }


            ticket.UpdatedAt = DateTime.Now;

            if (await _repo.Save())
            {
                var ticketToReturn = _mapper.Map <TicketDetailDto>(ticket);

                return(Ok(ticketToReturn));
            }


            return(BadRequest(new { error = "Ticket cannot be saved" }));
        }
Пример #6
0
 public async Task <IActionResult> Put(TicketUpdateDto ticketUpdateDto)
 {
     return(Ok(await _ticket.UpdateTicketAsync(ticketUpdateDto)));
 }