Пример #1
0
        /// <summary>
        /// Add mission and the correspondent agent and country
        /// </summary>
        /// <param name="mission"></param>
        /// <returns></returns>
        public async Task <bool> AddMission(MissionRequest missionRequest)
        {
            Mission mission = _mapper.Map <Mission>(missionRequest);

            //if agent already eixst we will not add another one
            Agent agent = await _missionRepository.GetAgentByName(mission.Agent.Name);

            mission.Agent = agent ?? mission.Agent;

            //if country already eixst we will not add another one
            Country country = await _missionRepository.GetCountryByName(mission.Country.Name);

            mission.Country = country ?? mission.Country;

            return(await _missionRepository.AddMission(mission));
        }