Beispiel #1
0
        public static void delete(int? assignmentID, SchedulerContext dbcontext)
        {
            if (assignmentID == null) { return; }

            Assignment a = dbcontext.Assignments.Find(assignmentID);
            dbcontext.Assignments.Remove(a);
            dbcontext.SaveChanges();
        }
Beispiel #2
0
        public static void delete(int? assignmentID)
        {
            if (assignmentID == null) { return; }

            using (var sc = new SchedulerContext()) {
                Assignment a = sc.Assignments.Find(assignmentID);
                sc.Assignments.Remove(a);
                sc.SaveChanges();
            }
        }
Beispiel #3
0
        public static void delete(int? personID)
        {
            if (personID == null) { return; }

            using (var sc = new SchedulerContext())
            {
                Person p = sc.Persons.Find(personID);
                // also remove any assignments associated with person p
                //p.Assignments = Assignment.getAssignmentsByPersonID(p.ID);

                //foreach (Assignment assignment in p.Assignments)
                //{
                //    Assignment.delete(assignment.ID);
                //}

                sc.Persons.Remove(p);
                sc.SaveChanges();
            }
        }
Beispiel #4
0
        public static void delete(int? eveID)
        {
            if (eveID == null) { return; }

            using (var sc = new SchedulerContext())
            {
                Event p = sc.Events.Find(eveID);
                // also remove assignments associated with event p
                //p.Assignments = Assignment.getAssignmentsByEvent(p.ID);

                //foreach (Assignment assignment in p.Assignments)
                //{

                //    sc.Assignments.Remove(assignment);
                //    sc.SaveChanges();
                //}

                sc.Events.Remove(p);
                sc.SaveChanges();
            }
        }
Beispiel #5
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 #6
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();
                    }
                }
            }
        }