public async Task CreateOrUpdateSpotConnectorInfo(SpotConnectorInfoCreateOrUpdateInput input)
        {
            await CheckValidation(input);

            if (input.Id.HasValue)
            {
                await UpdateSpotConnectorInfoAsync(input);
            }
            else
            {
                await CreateSpotConnectorInfoAsync(input);
            }
        }
        private async Task CheckValidation(SpotConnectorInfoCreateOrUpdateInput input)
        {
            var existingObj = (await _spotConnectorInfoRepository.GetAll().AsNoTracking()
                               .FirstOrDefaultAsync(l => l.Code == input.Code));

            if (existingObj != null && existingObj.Id != input.Id)
            {
                throw new UserFriendlyException(L("ThisCodeAlreadyExists"));
            }

            existingObj = (await _spotConnectorInfoRepository.GetAll().AsNoTracking()
                           .FirstOrDefaultAsync(l => l.Name == input.Name));
            if (existingObj != null && existingObj.Id != input.Id)
            {
                throw new UserFriendlyException(L("ThisNameAlreadyExists"));
            }
        }
        public async Task <SpotConnectorInfoCreateOrUpdateInput> GetSpotConnectorInfoForEdit(NullableIdDto <int> input)
        {
            //Getting all available roles
            var output = new SpotConnectorInfoCreateOrUpdateInput();

            if (input.Id.HasValue)
            {
                //Editing an existing user
                var spotConnectorInfo = await _spotConnectorInfoRepository.GetAsync(input.Id.Value);

                if (spotConnectorInfo != null)
                {
                    ObjectMapper.Map <SpotConnectorInfo, SpotConnectorInfoCreateOrUpdateInput>(spotConnectorInfo, output);
                }
            }

            return(output);
        }
 private async Task UpdateSpotConnectorInfoAsync(SpotConnectorInfoCreateOrUpdateInput input)
 {
     var spotConnectorInfo = ObjectMapper.Map <SpotConnectorInfo>(input);
     await _spotConnectorInfoRepository.UpdateAsync(spotConnectorInfo);
 }