Пример #1
0
        public async Task RemoveProfileAsync(Profile profile)
        {
            if (!_profiles.Contains(profile))
            {
                throw new ArgumentException("Unknown profile.");
            }

            if (_profiles.Count == 0)
            {
                throw new InvalidOperationException("Can't delete the last profile.");
            }

            if (profile == await ActiveProfile.LastAsync())
            {
                _activeProfile.OnNext(_profiles.Except(new[] { profile }).First());
            }

            _profiles.Remove(profile);

            profile.Changed -= ProfileOnChanged;

            var httpClient = _httpClientFactory.CreateClient(EndPoints.BackEnd);

            using var response = await httpClient.DeleteAsync($"profile/{profile.Id}");
        }