public T Ajouter(T nouveau) { try { T retour = contexte.Set <T>().Add(nouveau); contexte.SaveChanges(); return(retour); } catch (Exception) { throw; } }
partial void Execute_SavePatchCommand() { int wavetype = 0; if (WaveType == SignalGeneratorType.Sin) { wavetype = 0; } if (WaveType == SignalGeneratorType.Triangle) { wavetype = 1; } if (WaveType == SignalGeneratorType.SawTooth) { wavetype = 2; } if (WaveType == SignalGeneratorType.Square) { wavetype = 3; } if (WaveType == SignalGeneratorType.Pink) { wavetype = 4; } try { if (db.Syntheses.FirstOrDefault(u => u.Name == this.Name) == null) { Syntheses SynthObject = new Syntheses { Name = this.Name, Decay = this.Decay, Attack = this.Attack, ChorusDelay = this.ChorusDelay, ChorusSweep = this.ChorusSweep, ChorusWidth = this.ChorusWidth, PhaserDry = this.PhaserDry, PhaserFeedback = this.PhaserFeedback, PhaserFreq = this.PhaserFreq, PhaserSweep = this.PhaserSweep, PhaserWet = this.PhaserWet, PhaserWidth = this.PhaserWidth, CutOff = this.CutOff, Sustain = this.Sustain, Q = this.Q, Release = this.Release, TremoloFreq = this.TremoloFreq, Volume = this.Volume, TremoloGain = this.TremoloGain, Filter = EnableLpf, Vibrato = EnableVibrato, Date = DateTime.Now, WaveForm = wavetype, FactId = factory.id_factory }; db.Syntheses.Add(SynthObject); db.SaveChanges(); if (!IsEng) { ValidateBlock = ("Сохранено!"); } else { ValidateBlock = ("Saved!"); } this.Name = ""; } else { if (!IsEng) { ValidateBlock = ("Имя занято"); } else { ValidateBlock = ("Is not available"); } } SynthesesList = new ObservableCollection <Syntheses>(db.Syntheses.Where(p => p.FactId == factory.id_factory)); } catch (Exception) { NetworkError = true; } }