Ejemplo n.º 1
0
        public async Task ImportSequenceAsync(string sequenceFilename)
        {
            using (await _asyncLock.LockAsync())
            {
                var sequenceJson = await File.ReadAllTextAsync(sequenceFilename);

                var sequence = JsonConvert.DeserializeObject <Sequence>(sequenceJson);

                sequence.Id = 0;

                var sequenceName = sequence.Name;
                if (!IsSequenceNameAvailable(sequenceName))
                {
                    for (var suffix = 1; suffix < 1000; suffix++)
                    {
                        var newSequenceName = $"{sequenceName} {suffix}";
                        if (IsSequenceNameAvailable(newSequenceName))
                        {
                            sequenceName = newSequenceName;
                            break;
                        }
                    }
                }

                sequence.Name = sequenceName;
                await _creationRepository.InsertSequenceAsync(sequence);

                Sequences.Add(sequence);
            }
        }
Ejemplo n.º 2
0
        public async Task<Sequence> AddSequenceAsync(string sequenceName)
        {
            using (await _asyncLock.LockAsync())
            {
                var sequence = new Sequence { Name = sequenceName };
                await _creationRepository.InsertSequenceAsync(sequence);

                Sequences.Add(sequence);
                return sequence;
            }
        }