Пример #1
0
        //public async Task<bool> UpdateOrCreateClubContactMember(string clubName, ClubContactsViewModel clubContactUpdateViewModel)
        //{
        //	List<ClubContactsViewModel> contacts = new List<ClubContactsViewModel>();
        //	//var pilot = await _clubService.GetPilotById(clubContactUpdateViewModel.Id);
        //	Pilot pilot = clubContactUpdateViewModel as Pilot;
        //	//var members = await _clubService.GetClubMembers(clubName);
        //	/*var exist = _memberService.IsExist(pilot);
        //	if(exist.Result == false)
        //	{
        //		var p = await _memberService.AddPilot(pilot);
        //	}
        //	*/
        //	await _clubService.AddContactToClub(clubName, pilot);
        //	return await Task.FromResult<bool>(true);
        //}
        public async Task <bool> UpdateOrCreateClubContactMember(string clubName, ClubContactsModel objects)
        {
            List <ClubContactsModel> contacts = new List <ClubContactsModel>();
            //var pilot = await _clubService.GetPilotById(clubContactUpdateViewModel.Id);
            Pilot pilot = new Pilot();

            _mapper.Map <ClubContactsModel, Pilot>(objects, pilot);
            _mapper.Map <List <AddressModel>, ICollection <Address> >(objects.Addresses, pilot.Contact.Addresses);
            _mapper.Map <List <PhoneModel>, ICollection <Phone> >(objects.Phones, pilot.Contact.Phones);
            _mapper.Map <List <EMAILModel>, ICollection <EMAIL> >(objects.Emails, pilot.Contact.EMAILs);
            //var members = await _clubService.GetClubMembers(clubName);

            /*var exist = _memberService.IsExist(pilot);
             * if(exist.Result == false)
             * {
             *      var p = await _memberService.AddPilot(pilot);
             * }
             */
            if (pilot.Id == 0)
            {
                await _memberService.AddPilot(pilot);
            }
            await _clubService.AddContactToClub(clubName, pilot);

            return(await Task.FromResult <bool>(true));
        }