Ejemplo n.º 1
0
        public async Task <TicketCreateResponse> AddRequerimentNoRenew([FromForm] string customerId, [FromForm] string assetId, [FromForm] List <IFormFile> attachments)
        {
            try {
                var user = await _customerUserRepository.GetCustomerUserByCip(customerId);

                var asset = await _assetRepository.GetAssetById(assetId);

                if (user == null || asset == null)
                {
                    return(new TicketCreateResponse());
                }

                TicketIncidenceCreate ticket = new TicketIncidenceCreate {
                    UserCip       = user.CustomerId,
                    OtrsServiceId = _ticketSettings.AssetReturnTerminationServiceID,
                    Description   = $"Apellidos: {user.LastName}\n" +
                                    $"Nombres: {user.FirstName}\n" +
                                    $"Ubicación: {user.Street}\n" +
                                    $"Tipo de equipo: {asset.Type}\n" +
                                    $"Inventario: {asset.Name}\n" +
                                    $"Serie del equipo: {asset.SerieNro}\n" +
                                    $"Ubicación: {user.Street}\n" +
                                    $"Celular: {user.Phone}\n",
                    Asset       = asset,
                    Attachments = _mapper.Map <List <TicketAttachments> >(_convertFileExtensions.ListConvertFileToBase64(attachments))
                };
                var result = _ticketRepository.AddTicketNoRenewOtrs(
                    _mapper.Map <TicketCredencials>(_otrsCredencialsService.GetOtrsCredencials()),
                    ticket);

                return(result);
            } catch {
                return(new TicketCreateResponse());
            }
        }