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); } }
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 LoadCreationsAndSequencesAsync() { using (await _asyncLock.LockAsync()) { Creations.Clear(); var creations = await _creationRepository.GetCreationsAsync(); foreach (var creation in creations) { Creations.Add(creation); } Sequences.Clear(); var sequences = await _creationRepository.GetSequencesAsync(); foreach (var sequence in sequences) { Sequences.Add(sequence); } } }