예제 #1
0
파일: ApiProfiles.cs 프로젝트: Ifry/win-app
        public async Task Update(Profile profile)
        {
            Ensure.NotNull(profile, nameof(profile));
            Ensure.IsTrue(!profile.IsPredefined, "Can't update predefined profile");
            Ensure.IsTrue(profile.IsColorCodeValid());

            ApiResponseResult <ProfileResponse> response = await HandleErrors(
                () => _apiClient.UpdateProfile(profile.ExternalId, ToApiProfile(profile)));

            UpdatePropertiesFromApiProfile(profile, response.Value.Profile);
        }
예제 #2
0
        public static bool IsValid(this Profile profile)
        {
            if (profile == null)
            {
                return(false);
            }

            // The old ServerId (mapped to LogicalID on the API) value might be not mapped by the profile migration.
            if (!string.IsNullOrEmpty(profile.ServerId) && profile.ServerId.Length < 5)
            {
                return(false);
            }

            return(profile.IsColorCodeValid());
        }