Beispiel #1
0
        public Ansatt Save()
        {
            var db = new TimeplanEntities();

            var ansatt = Id > 0 ? GetById(Id, db) : new Ansatt();

            if (ansatt != null) // or else it is deleted
            {
                ansatt.Copy(this, db);

                if (Id <= 0)
                {
                    db.Ansatts.Add(ansatt);
                }

                db.SaveChanges();

                Id = ansatt.Id;

                SaveAnsattTilstedes();
            }

            IsChanged = false;

            return(ansatt);
        }
Beispiel #2
0
        public Elev Save()
        {
            var db = new TimeplanEntities();

            var elev = Id > 0 ? GetById(Id, db) : new Elev();

            if (elev != null) // or else it is deleted
            {
                elev.Copy(this, db);

                if (Id <= 0)
                {
                    db.Elevs.Add(elev);
                }

                db.SaveChanges();

                Id = elev.Id;

                SaveElevTilstedes();
            }

            IsChanged = false;

            return(elev);
        }
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var stillingsType = GetById(Id, db);

                if (stillingsType != null)
                {
                    db.StillingsTypes.Remove(stillingsType);

                    db.SaveChanges();
                }
            }
        }
Beispiel #4
0
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var ukeType = GetById(Id, db);

                if (ukeType != null) // or else it is already deleted
                {
                    db.UkeTypes.Remove(ukeType);

                    db.SaveChanges();
                }
            }
        }
Beispiel #5
0
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var trinn = GetById(Id, db);

                if (trinn != null)
                {
                    db.Trinns.Remove(trinn);

                    db.SaveChanges();
                }
            }
        }
Beispiel #6
0
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var bemanningsNorm = GetById(Id, db);

                if (bemanningsNorm != null)
                {
                    db.BemanningsNorms.Remove(bemanningsNorm);

                    db.SaveChanges();
                }
            }
        }
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var elevTilstede = GetById(Id, db);

                if (elevTilstede != null)
                {
                    db.ElevTilstedes.Remove(elevTilstede);

                    db.SaveChanges();
                }
            }
        }
Beispiel #8
0
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var klasse = GetById(Id, db);

                if (klasse != null)
                {
                    db.Klasses.Remove(klasse);

                    db.SaveChanges();
                }
            }
        }
Beispiel #9
0
        public void Delete()
        {
            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var sfo = GetById(Id, db);

                if (sfo != null)
                {
                    sfo.Elevs.Clear();
                    sfo.Ansatts.Clear();

                    db.Sfoes.Remove(sfo);

                    db.SaveChanges();
                }
            }
        }
Beispiel #10
0
        public void Delete()
        {
            // TODO: probably the simplest/easiest way, but exception or error code enum might be better...
            // could also split method and use bool CanDelete()...
            //var message = string.Empty;

            //var db = new TimeplanEntities();

            //var avdeling = Id > 0 ? GetById(Id, db) : this;

            //if (Id > 0 &&
            //    (avdeling.Ansatts.Count > 0 ||
            //    avdeling.Klasses.Count > 0))
            //{
            //    message = @"Ansatte og klasser må overføres til andre avdelinger før avdeling '" + avdeling.Navn + "' kan slettes.";
            //}
            //else
            //{
            //    if (Id > 0)
            //    {
            //        db.Avdelings.Remove(avdeling);
            //    }

            //    db.SaveChanges();
            //}

            //return message;

            if (Id > 0)
            {
                var db = new TimeplanEntities();

                var avdeling = GetById(Id, db);

                if (avdeling != null)
                {
                    db.Avdelings.Remove(avdeling);

                    db.SaveChanges();
                }
            }
        }
Beispiel #11
0
        public void Delete()
        {
            if (Id > 0)
            {
                foreach (AnsattTilstede ansattTilstede in AnsattTilstedes)
                {
                    ansattTilstede.Delete();
                }

                var db = new TimeplanEntities();

                var ansatt = GetById(Id, db);

                ansatt.JobberISfos.Clear();
                ansatt.JobberIKlasser.Clear();

                db.Ansatts.Remove(ansatt);

                db.SaveChanges();
            }
        }
Beispiel #12
0
        public void Delete()
        {
            if (Id > 0)
            {
                foreach (ElevTilstede elevTilstede in ElevTilstedes)
                {
                    elevTilstede.Delete();
                }

                var db = new TimeplanEntities();

                var elev = GetById(Id, db);

                if (elev != null)
                {
                    db.Elevs.Remove(elev);

                    db.SaveChanges();
                }
            }
        }
Beispiel #13
0
        public ElevTilstede Save()
        {
            var db = new TimeplanEntities();

            var elevTilstede = Id > 0 ? GetById(Id, db) : new ElevTilstede();

            if (elevTilstede != null)
            {
                elevTilstede.Copy(this);

                if (Id <= 0)
                {
                    db.ElevTilstedes.Add(elevTilstede);
                }

                db.SaveChanges();

                Id = elevTilstede.Id;
            }

            IsChanged = false;

            return(elevTilstede);
        }
Beispiel #14
0
        public Sfo Save()
        {
            var db = new TimeplanEntities();

            var sfo = Id > 0 ? GetById(Id, db) : new Sfo();

            if (sfo != null)
            {
                sfo.Copy(this, db);

                if (Id <= 0)
                {
                    db.Sfoes.Add(sfo);
                }

                db.SaveChanges();

                Id = sfo.Id;
            }

            IsChanged = false;

            return(sfo);
        }
Beispiel #15
0
        public Trinn Save()
        {
            var db = new TimeplanEntities();

            var trinn = Id > 0 ? GetById(Id, db) : new Trinn();

            if (trinn != null)
            {
                trinn.Copy(this, db);

                if (Id <= 0)
                {
                    db.Trinns.Add(trinn);
                }

                db.SaveChanges();

                Id = trinn.Id;
            }

            IsChanged = false;

            return(trinn);
        }
Beispiel #16
0
        public BemanningsNorm Save()
        {
            var db = new TimeplanEntities();

            var bemanningsNorm = Id > 0 ? GetById(Id, db) : new BemanningsNorm();

            if (bemanningsNorm != null)
            {
                bemanningsNorm.Copy(this, db);

                if (Id <= 0)
                {
                    db.BemanningsNorms.Add(bemanningsNorm);
                }

                db.SaveChanges();

                Id = bemanningsNorm.Id;
            }

            IsChanged = false;

            return(bemanningsNorm);
        }
Beispiel #17
0
        public Avdeling Save()
        {
            var db = new TimeplanEntities();

            var avdeling = Id > 0 ? GetById(Id, db) : new Avdeling();

            if (avdeling != null)
            {
                avdeling.Copy(this, db);

                if (Id <= 0)
                {
                    db.Avdelings.Add(avdeling);
                }

                db.SaveChanges();

                Id = avdeling.Id;
            }

            IsChanged = false;

            return(avdeling);
        }
Beispiel #18
0
        public UkeType Save()
        {
            var db = new TimeplanEntities();

            var ukeType = Id > 0 ? GetById(Id, db) : new UkeType();

            if (ukeType != null) // or else it is deleted
            {
                ukeType.Copy(this, db);

                if (Id <= 0)
                {
                    db.UkeTypes.Add(ukeType);
                }

                db.SaveChanges();

                Id = ukeType.Id;
            }

            IsChanged = false;

            return(ukeType);
        }
Beispiel #19
0
        public Klasse Save()
        {
            var db = new TimeplanEntities();

            var klasse = Id > 0 ? GetById(Id, db) : new Klasse();

            if (klasse != null)
            {
                klasse.Copy(this, db);

                if (Id <= 0)
                {
                    db.Klasses.Add(klasse);
                }

                db.SaveChanges();

                Id = klasse.Id;
            }

            IsChanged = false;

            return(klasse);
        }
        public StillingsType Save()
        {
            var db = new TimeplanEntities();

            var stillingsType = Id > 0 ? GetById(Id, db) : new StillingsType();

            if (stillingsType != null)
            {
                stillingsType.Copy(this, db);

                if (Id <= 0)
                {
                    db.StillingsTypes.Add(stillingsType);
                }

                db.SaveChanges();

                Id = stillingsType.Id;
            }

            IsChanged = false;

            return(stillingsType);
        }