public async Task <bool> ChangePassengerInfo(PassengerDto p)
        {
            try
            {
                _memoryCache.TryGetValue(PassengerKey, out List <PassengerDto> pCache);
                _memoryCache.TryGetValue(DocumentTypeKey, out List <DocumentTypeDto> dCache);

                var passenger = pCache.Find(c => c.Id == p.Id);
                if (passenger != null)
                {
                    p.Adapt(passenger);
                    passenger.DocumentType = dCache.Find(c => c.Id == p.DocumentTypeId);
                    passenger.IssueDate    = DateTime.UtcNow;
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
            finally
            {
                await Task.Delay(new TimeSpan(0));
            }
        }
Esempio n. 2
0
 public async Task <bool> AddNewPassenger(PassengerDto p)
 {
     try
     {
         var newPassenger = p.Adapt(new Data.Entity.Passenger());
         return(newPassenger != null && await _passengerRepository.CreateAsync(newPassenger));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Esempio n. 3
0
        public async Task <bool> ChangePassengerInfo(PassengerDto p)
        {
            try
            {
                var passenger = await _passengerRepository.GetByIdAsync(p.Id);

                if (passenger != null)
                {
                    var updatedPassenger = p.Adapt(passenger);
                    return(updatedPassenger != null && await _passengerRepository.UpdateAsync(updatedPassenger));
                }

                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }