/// <summary> /// SaveContractContact /// </summary> /// <param name="contractStaticViewModel"></param> /// <param name="loggedUser"></param> /// <returns>Task<BaseResult<long>></returns> private async Task <BaseResult <long> > SaveContractContact(ContractStaticViewModel contractStaticViewModel, string loggedUser) { var insertList = new List <ContractContact>(); var updateList = new List <ContractContact>(); var result = new BaseResult <long>(); foreach (var item in contractStaticViewModel.HotelDetailsViewModel.ContactDetails) { if (item.ObjectState == ObjectState.Added) { item.HotelId = contractStaticViewModel.HotelDetailsViewModel.HotelId; var contractContactViewModel = DbMapperMasterdata.AutomapperContractContactViewModel(item); var contractContactModel = DbMapperMasterdata.AutomapperContractContact(contractContactViewModel, loggedUser); contractContactModel.ContractId = contractStaticViewModel.ContractId; insertList.Add(contractContactModel); } if (item.ObjectState == ObjectState.Modified) { item.HotelId = contractStaticViewModel.HotelDetailsViewModel.HotelId; var contractContactViewModel = DbMapperMasterdata.AutomapperContractContactViewModel(item); var contractContactModel = DbMapperMasterdata.AutomapperContractContact(contractContactViewModel, loggedUser); contractContactModel.ContractId = contractStaticViewModel.ContractId; updateList.Add(contractContactModel); } } if (insertList.Count > 0) { result = await iContractContact.InsertEntityList(insertList).ConfigureAwait(false); if (result != null && result.Result > 0) { result.Result = contractStaticViewModel.ContractId; } else { result.IsError = true; } } if (updateList.Count > 0) { var updateResult = await iContractContact.UpdateEntityList(updateList).ConfigureAwait(false); if (updateResult.Result) { result.Result = contractStaticViewModel.ContractId; } else { result.IsError = true; } } return(result); }
private async Task <BaseResult <long> > SaveContractContact(ContractStaticViewModel contractStaticViewModel, string loggedUser) { var contractContactList = new List <ContractContact>(); foreach (var item in contractStaticViewModel.HotelDetailsViewModel.ContactDetails) { if (item.ObjectState == ObjectState.Added) { item.HotelId = contractStaticViewModel.HotelDetailsViewModel.HotelId; var contractContactViewModel = DbMapperMasterdata.AutomapperContractContactViewModel(item); var contractContactModel = DbMapperMasterdata.AutomapperContractContact(contractContactViewModel, loggedUser); contractContactModel.Contractid = contractStaticViewModel.ContractId; contractContactList.Add(contractContactModel); } } var result = await iContractContact.InsertEntityList(contractContactList).ConfigureAwait(false); return(result); }