public virtual void init()
 {
     NHibernateDaoFactory df = new NHibernateDaoFactory();
     this.view.AutorList = df.getAutorDao().getAllSortedBy(true, Autor.Property.Name.ToString());
     this.view.BpmList = df.getBpmDao().getAllSortedBy(true, Bpm.Property.Value.ToString());
     this.view.CodeList = df.getCodeDao().getAllSortedBy(true, Code.Property.Name.ToString());
     this.view.EndingList = new List<Ending.Attribute>(Enum.GetValues(typeof(Ending.Attribute)) as IEnumerable<Ending.Attribute>);
     this.view.InterpretList = df.getInterpretDao().getAllSortedBy(true, Interpret.Property.Name.ToString());
     this.view.LabelList = df.getLabelDao().getAllSortedBy(true, Label.Property.Name.ToString());
     this.view.LaengeList = df.getLaengeDao().getAllSortedBy(true, Laenge.Property.Dauer.ToString());
     this.view.TitelList = df.getTitelDao().getAllSortedBy(true, Titel.Property.Name.ToString());
     this.view.VerlagList = df.getVerlagDao().getAllSortedBy(true, Verlag.Property.Name.ToString());
     this.view.YearList = df.getYearDao().getAllSortedBy(true, Year.Property.Value.ToString());
 }
        public override void update()
        {
            Track original = dao.GetById(this.view.TrackToEditID, true);
            Track new1 = this.view.TrackToCreate;

            if(original.Equals(new1))
                return;

            // Does edited track already exist?
            ICriteria c = NHibernateSessionManager.Instance.GetSession().CreateCriteria(typeof(Track));
            c.Add(Example.Create(new1)).CreateCriteria("Autor").Add(Example.Create(new1.Autor));
            c.Add(Example.Create(new1)).CreateCriteria("Bpm").Add(Example.Create(new1.Bpm).ExcludeNone());
            c.Add(Example.Create(new1)).CreateCriteria("Interpret").Add(Example.Create(new1.Interpret));
            c.Add(Example.Create(new1)).CreateCriteria("Label").Add(Example.Create(new1.Label));
            c.Add(Example.Create(new1)).CreateCriteria("Code").Add(Example.Create(new1.Code));
            c.Add(Example.Create(new1)).CreateCriteria("Laenge").Add(Example.Create(new1.Laenge));
            c.Add(Example.Create(new1)).CreateCriteria("Titel").Add(Example.Create(new1.Titel));
            c.Add(Example.Create(new1)).CreateCriteria("Verlag").Add(Example.Create(new1.Verlag));
            c.Add(Example.Create(new1)).CreateCriteria("Year").Add(Example.Create(new1.Year).ExcludeNone());
            c.Add(Expression.Eq("Ending.Value", new1.Ending.Value));

            Track existing = c.UniqueResult<Track>();

            if(existing != null) {
                foreach(Einsatz einsatz in original.Einsaetze)
                    einsatz.Track = existing;
            }
            else {
                NHibernateDaoFactory df = new NHibernateDaoFactory();
                if(!original.Autor.Equals(new1.Autor))
                    original.Autor = df.getAutorDao().save(new1.Autor);
                original.Bpm = df.getBpmDao().save(new1.Bpm);
                if(!original.Code.Equals(new1.Code))
                    original.Code = df.getCodeDao().save(new1.Code);
                if(!original.Interpret.Equals(new1.Interpret))
                    original.Interpret = df.getInterpretDao().save(new1.Interpret);
                if(!original.Label.Equals(new1.Label))
                    original.Label = df.getLabelDao().save(new1.Label);
                if(!original.Laenge.Equals(new1.Laenge))
                    original.Laenge = df.getLaengeDao().save(new1.Laenge);
                if(!original.Titel.Equals(new1.Titel))
                    original.Titel = df.getTitelDao().save(new1.Titel);
                if(!original.Verlag.Equals(new1.Verlag))
                    original.Verlag = df.getVerlagDao().save(new1.Verlag);
                original.Year = df.getYearDao().save(new1.Year);
                original.Ending.Value = new1.Ending.Value;
            }
        }