public void Add(Sequence sequence) { // see if sequence exists var anySequences = _context.LauncherSequences .Any(t => t.Name.Equals(sequence.Name, StringComparison.InvariantCultureIgnoreCase) && t.LauncherClient.Name.Equals(sequence.LauncherName, StringComparison.InvariantCultureIgnoreCase)); if (anySequences) { throw new DataException("Sequence in this launcher with this name already exists: " + sequence.Name + ", " + sequence.LauncherName); } var launcher = _context.LauncherClients.Single(t => t.Name.Equals(sequence.LauncherName, StringComparison.InvariantCultureIgnoreCase)); var toAdd = new LauncherSequence { LauncherClientId = launcher.Id, Name = sequence.Name, LauncherSequenceItems = sequence.Sequences.Select(b => new LauncherSequenceItem { Command = b.Command, TimeInMs = b.Length }).ToList() }; _context.LauncherSequences.Add(toAdd); _context.SaveChanges(); }
public void Post(string launcherName, Sequence sequence) { _service.Add(sequence); }