public async Task UpdateCreationAsync(Creation creation)
 {
     using (await _lock.LockAsync())
     {
         await _databaseConnection.UpdateAsync(creation);
     }
 }
 public async Task DeleteCreationAsync(Creation creation)
 {
     using (await _lock.LockAsync())
     {
         await _databaseConnection.DeleteAsync(creation, true);
     }
 }
Example #3
0
 public async Task <bool> IsControllerProfileNameAvailableAsync(Creation creation, string controllerProfileName)
 {
     using (await _asyncLock.LockAsync())
     {
         return(creation.ControllerProfiles.All(cp => cp.Name != controllerProfileName));
     }
 }
        public async Task ImportControllerProfileAsync(Creation creation, string controllerProfileFilename)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerProfileJson = await File.ReadAllTextAsync(controllerProfileFilename);

                var controllerProfile = JsonConvert.DeserializeObject <ControllerProfile>(controllerProfileJson);

                controllerProfile.Creation   = null;
                controllerProfile.CreationId = 0;

                var controllerProfileName = controllerProfile.Name;
                if (!IsControllerProfileNameAvailable(creation, controllerProfileName))
                {
                    for (var suffix = 1; suffix < 1000; suffix++)
                    {
                        var newControllerProfileName = $"{controllerProfileName} {suffix}";
                        if (IsControllerProfileNameAvailable(creation, newControllerProfileName))
                        {
                            controllerProfileName = newControllerProfileName;
                            break;
                        }
                    }
                }

                controllerProfile.Name = controllerProfileName;
                await _creationRepository.InsertControllerProfileAsync(creation, controllerProfile);
            }
        }
 public async Task <bool> IsControllerProfileNameAvailableAsync(Creation creation, string controllerProfileName)
 {
     using (await _asyncLock.LockAsync())
     {
         return(IsControllerProfileNameAvailable(creation, controllerProfileName));
     }
 }
 public async Task ExportCreationAsync(Creation creation, string creationFilename)
 {
     using (await _asyncLock.LockAsync())
     {
         var creationJson = JsonConvert.SerializeObject(creation);
         await File.WriteAllTextAsync(creationFilename, creationJson);
     }
 }
 public async Task RenameCreationAsync(Creation creation, string newName)
 {
     using (await _asyncLock.LockAsync())
     {
         creation.Name = newName;
         await _creationRepository.UpdateCreationAsync(creation);
     }
 }
Example #8
0
 public async Task DeleteCreationAsync(Creation creation)
 {
     using (await _asyncLock.LockAsync())
     {
         await _creationRepository.DeleteCreationAsync(creation);
         Creations.Remove(creation);
     }
 }
        public async Task InsertCreationAsync(Creation creation)
        {
            using (await _lock.LockAsync())
            {
                await InitAsync();

                await _databaseConnection.InsertAsync(creation);
            }
        }
Example #10
0
 public async Task<ControllerProfile> AddControllerProfileAsync(Creation creation, string controllerProfileName)
 {
     using (await _asyncLock.LockAsync())
     {
         var controllerProfile = new ControllerProfile { Name = controllerProfileName };
         await _creationRepository.InsertControllerProfileAsync(creation, controllerProfile);
         return controllerProfile;
     }
 }
Example #11
0
 public async Task<Creation> AddCreationAsync(string creationName)
 {
     using (await _asyncLock.LockAsync())
     {
         var creation = new Creation { Name = creationName };
         await _creationRepository.InsertCreationAsync(creation);
         Creations.Add(creation);
         return creation;
     }
 }
        public async Task InsertControllerProfileAsync(Creation creation, ControllerProfile controllerProfile)
        {
            using (await _lock.LockAsync())
            {
                await _databaseConnection.InsertAsync(controllerProfile);

                if (creation.ControllerProfiles == null)
                {
                    creation.ControllerProfiles = new ObservableCollection <ControllerProfile>();
                }

                creation.ControllerProfiles.Add(controllerProfile);
                await _databaseConnection.UpdateWithChildrenAsync(creation);
            }
        }
Example #13
0
        public async Task InsertCreationAsync(Creation creation)
        {
            using (await _lock.LockAsync())
            {
                await InitAsync();

                await _databaseConnection.InsertAsync(creation);

                // insert all available profiles as well as it's present for a creation when it's imported only
                if (creation.ControllerProfiles.Any())
                {
                    foreach (var profile in creation.ControllerProfiles)
                    {
                        await InsertControllerProfileAsync(profile);
                    }
                    await _databaseConnection.UpdateWithChildrenAsync(creation);
                }
            }
        }
 private bool IsControllerProfileNameAvailable(Creation creation, string controllerProfileName)
 {
     return(creation.ControllerProfiles.All(cp => cp.Name != controllerProfileName));
 }