Ejemplo n.º 1
0
        public void editActivity(SingleActivity acti, int id)
        {
            string te = activities[id].teacher;
            string sl = activities[id].slot.ToString();

            //string te = "Zbyszek";
            //string sl = "13";

            using (var context = new LibraryContext())
            {
                var teach       = context.Teacher;
                var subs        = context.Subject;
                var groupss     = context.Classgroup;
                var roomss      = context.Room;
                var slotss      = context.Slot;
                var activitiess = context.ActivityBis.Include(p => p.Slot).Include(t => t.Teacher).Include(r => r.Room)
                                  .Include(c => c.Classgroup).Include(s => s.Subject);

                var ActivitiesBis = from a in activitiess where (a.Teacher.name == te && a.Slot.name == sl) select a;
                var activityTer   = ActivitiesBis.Single();

                foreach (var s in subs)
                {
                    if (s.name == acti.subject)
                    {
                        activityTer.Subject = s;
                    }
                }

                foreach (var t in teach)
                {
                    if (t.name == acti.teacher)
                    {
                        activityTer.Teacher = t;
                    }
                }

                foreach (var g in groupss)
                {
                    if (g.name == acti.group)
                    {
                        activityTer.Classgroup = g;
                    }
                }

                foreach (var r in roomss)
                {
                    if (r.name == acti.room)
                    {
                        activityTer.Room = r;
                    }
                }

                activityTer.TimeStamp = DateTime.Now;
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void ReadActivities()
        {
            activities = new List <SingleActivity>();

            using (var context = new LibraryContext())
            {
                var activitiess = context.ActivityBis.Include(s => s.Slot).Include(r => r.Room).Include(t => t.Teacher)
                                  .Include(x => x.Subject).Include(c => c.Classgroup);

                foreach (var t in activitiess)
                {
                    SingleActivity acti = new SingleActivity();
                    acti.slot = Int32.Parse(t.Slot.name);

                    acti.subject = t.Subject.name;
                    acti.teacher = t.Teacher.name;
                    acti.room    = t.Room.name;
                    acti.group   = t.Classgroup.name;

                    activities.Add(acti);
                }
            }
        }
Ejemplo n.º 3
0
        public void InsertActivity(SingleActivity act)
        {
            using (var context = new LibraryContext())
            {
                // Creates the database if not exists
                context.Database.EnsureCreated();

                int checkBis    = 0;
                var teach       = context.Teacher;
                var subs        = context.Subject;
                var groupss     = context.Classgroup;
                var roomss      = context.Room;
                var slotss      = context.Slot;
                var activitiess = context.ActivityBis.Include(p => p.Slot);



                ActivityBis activityBis = new ActivityBis();

                foreach (var s in subs)
                {
                    if (s.name == act.subject)
                    {
                        activityBis.Subject = s;
                    }
                }

                foreach (var t in teach)
                {
                    if (t.name == act.teacher)
                    {
                        activityBis.Teacher = t;
                    }
                }

                foreach (var g in groupss)
                {
                    if (g.name == act.group)
                    {
                        activityBis.Classgroup = g;
                    }
                }

                foreach (var r in roomss)
                {
                    if (r.name == act.room)
                    {
                        activityBis.Room = r;
                    }
                }

                foreach (var s in slotss)
                {
                    if (s.name == act.slot.ToString())
                    {
                        activityBis.Slot = s;
                        checkBis         = 1;
                    }
                }

                if (checkBis == 0)
                {
                    Slot slot = new Slot();
                    slot.name    = act.slot.ToString();
                    slot.comment = " ";
                    context.Slot.Add(slot);
                    activityBis.Slot = slot;
                }

                activityBis.TimeStamp = DateTime.Now;
                context.ActivityBis.Add(activityBis);
                context.SaveChanges();
            }
        }