Esempio n. 1
0
        private void ProcessRequestDestinationData(IEnumerable <Destination> list, DataOP op)
        {
            if (list == null)
            {
                return;
            }

            foreach (Destination g in list)
            {
                if (DataOP.AddNew == op)
                {
                    g.RequestHeaderId = RequestHeader.Id;
                    _destinationRepository.Add(g);
                }

                if (DataOP.DEL == op)
                {
                    var user = _destinationRepository.GetById(g.Id);
                    _destinationRepository.Delete(user);
                }

                if (DataOP.EDIT == op)
                {
                    _destinationRepository.Update(g);
                }
            }
        }
 public async Task <ActionResult <DestinationDto> > PostEvent(DestinationDto destinationDto)
 {
     try
     {
         var mappedEntity = _mapper.Map <Destination>(destinationDto);
         _destinationRepository.Add(mappedEntity);
         if (await _destinationRepository.Save())
         {
             return(Created($"/api/v1.0/Destinations/{mappedEntity.Id}", _mapper.Map <Destination>(mappedEntity)));
         }
     }
     catch (Exception e)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
     }
     return(BadRequest());
 }
        public async Task <CommandResult <Guid> > CreateDestination(DestinationModel model)
        {
            try
            {
                if (model.DestinationId == null || model.DestinationId == Guid.Empty)
                {
                    model.DestinationId = Guid.NewGuid();
                }

                var destination = _mapper.Map <DestinationModel, DestinationEntity>(model);
                await _destinationRepository.Add(destination);

                return(new CommandResult <Guid>(destination.DestinationId));
            }
            catch (Exception exception)
            {
                return(new CommandResult <Guid>(exception.Message));
            }
        }
        public async Task Execute(DestinationInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var destinations = input.Destinations.Select(d =>
                                                         new Destination()
            {
                AirlineId = d.AirlineId,
                Country   = d.Country
            }).ToList();

            await _destinationRepository.Add(destinations);

            var airlineOutput = new DestinationOutput(destinations);

            _outputHandler.Standard(airlineOutput);
        }