public async Task ImportCreationAsync(string creationFilename)
        {
            using (await _asyncLock.LockAsync())
            {
                var creationJson = await File.ReadAllTextAsync(creationFilename);

                var creation = JsonConvert.DeserializeObject <Creation>(creationJson);

                var creationName = creation.Name;
                if (!IsCreationNameAvailable(creationName))
                {
                    for (var suffix = 1; suffix < 1000; suffix++)
                    {
                        var newCreationName = $"{creationName} {suffix}";
                        if (IsCreationNameAvailable(newCreationName))
                        {
                            creationName = newCreationName;
                            break;
                        }
                    }
                }

                creation.Name = creationName;
                await _creationRepository.InsertCreationAsync(creation);

                Creations.Add(creation);
            }
        }
Beispiel #2
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;
     }
 }