Esempio n. 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();
        }
Esempio n. 2
0
        public static Role getRoleByID(int roleID)
        {
            Role role = new Role();

            using (var sc = new SchedulerContext()) {
                role = sc.Roles.Where(r => r.ID == roleID).SingleOrDefault();
            }
            return role;
        }
Esempio n. 3
0
        public static List<Role> getAll()
        {
            List<Role> roles = new List<Role>();

            using (var sc = new SchedulerContext()) {
                roles = sc.Roles.ToList();
            }
            return roles;
        }
Esempio n. 4
0
        public static List<Person> getAll()
        {
            List<Person> persons = new List<Person>();

            using (var sc = new SchedulerContext())
            {
                persons = sc.Persons.ToList();
            }
            return persons;
        }
Esempio n. 5
0
        public static Role getRoleByName(string Name)
        {
            Role role = new Role();

            using (var sc = new SchedulerContext())
            {
                role = sc.Roles.Where(r => r.Name == Name).SingleOrDefault();
            }
            return role;
        }
Esempio n. 6
0
        public static List<Event> getAll()
        {
            List<Event> events = new List<Event>();

            using (var sc = new SchedulerContext())
            {
                events = sc.Events.ToList();
            }
            return events;
        }
Esempio n. 7
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();
            }
        }
Esempio n. 8
0
        public static Person getPersonByID(int? personID)
        {
            if (personID == null) { return null;  }

            Person person = new Person();

            using (var sc = new SchedulerContext()) {
                person = sc.Persons.Where(p => p.ID == personID).SingleOrDefault();
            }

            return person;
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
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();
            }
        }
Esempio n. 11
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();
                            }
                }
            }
        }
Esempio n. 12
0
        public static Event getEventByID(int eventID)
        {
            Event eve = new Event();

            using (var sc = new SchedulerContext())
            {
                eve = sc.Events.Where(e => e.ID == eventID).SingleOrDefault();
            }

            return eve;
        }
Esempio n. 13
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();
                    }
                }
            }
        }
Esempio n. 14
0
        public static List<Assignment> getAssignmentsByEvent(int eventID)
        {
            List<Assignment> Assignments = new List<Assignment>();

            using (var sc = new SchedulerContext()) {
                Assignments = sc.Assignments.Where(a => a.EventID == eventID).ToList();
            }

            return Assignments;
        }
Esempio n. 15
0
        public static List<Assignment> getAll()
        {
            List<Assignment> assignments = new List<Assignment>();

            using (var sc = new SchedulerContext())
            {
                assignments = sc.Assignments.ToList();
            }
            return assignments;
        }
Esempio n. 16
0
        public static List<Assignment> getAssignmentsByPersonID(int? personID)
        {
            if (personID == null) { return null;  }

            List<Assignment> Assignments = new List<Assignment>();

            using (var sc = new SchedulerContext()) {
                Assignments = sc.Assignments.Where(a => a.PersonID == personID).ToList();
            }

            return Assignments;
        }