Beispiel #1
0
        public void save()
        {
            if (this.ID <= 0) {
                //new person
                if (this.FirstName != null && this.FirstName.Length > 0 &&
                    this.LastName != null && this.LastName.Length > 0 &&
                    this.Email != null && this.Email.Length > 0) {

                        using (var sc = new SchedulerContext()) {
                            sc.Persons.Add(this);
                            sc.SaveChanges();
                        }
                }
            }
            else {
                //update existing
                if (this.FirstName != null && this.FirstName.Length > 0 &&
                    this.LastName != null && this.LastName.Length > 0 &&
                    this.Email != null && this.Email.Length > 0) {

                        using (var sc = new SchedulerContext()) {
                                sc.Persons.Attach(this);
                                sc.Entry(this).State = EntityState.Modified;
                                sc.SaveChanges();
                            }
                }
            }
        }
Beispiel #2
0
        public void save()
        {
            if (this.ID <= 0)
            {
                //new person
                if (this.Name != null && this.Name.Length > 0 &&
                    this.Room != null && this.Room.Length > 0 &&
                    this.EventDate != null &&
                    this.StartTime != null &&
                    this.EndTime != null)
                {

                    using (var sc = new SchedulerContext())
                    {
                        sc.Events.Add(this);
                        sc.SaveChanges();
                    }
                }
            }
            else {
                //update existing
                if (this.Name != null && this.Name.Length > 0 &&
                    this.Room != null && this.Room.Length > 0 &&
                    this.EventDate != null &&
                    this.StartTime != null &&
                    this.EndTime != null)
                {

                    using (var sc = new SchedulerContext())
                    {
                        sc.Events.Attach(this);
                        sc.Entry(this).State = EntityState.Modified;
                        sc.SaveChanges();
                    }
                }
            }
        }