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);
     }
 }
Exemplo n.º 3
0
 public async Task <bool> IsControllerProfileNameAvailableAsync(Creation creation, string controllerProfileName)
 {
     using (await _asyncLock.LockAsync())
     {
         return(creation.ControllerProfiles.All(cp => cp.Name != controllerProfileName));
     }
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
 public async Task <bool> IsControllerProfileNameAvailableAsync(Creation creation, string controllerProfileName)
 {
     using (await _asyncLock.LockAsync())
     {
         return(IsControllerProfileNameAvailable(creation, controllerProfileName));
     }
 }
Exemplo n.º 6
0
 public async Task ExportCreationAsync(Creation creation, string creationFilename)
 {
     using (await _asyncLock.LockAsync())
     {
         var creationJson = JsonConvert.SerializeObject(creation);
         await File.WriteAllTextAsync(creationFilename, creationJson);
     }
 }
Exemplo n.º 7
0
 public async Task RenameCreationAsync(Creation creation, string newName)
 {
     using (await _asyncLock.LockAsync())
     {
         creation.Name = newName;
         await _creationRepository.UpdateCreationAsync(creation);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 14
0
 private bool IsControllerProfileNameAvailable(Creation creation, string controllerProfileName)
 {
     return(creation.ControllerProfiles.All(cp => cp.Name != controllerProfileName));
 }