Exemplo n.º 1
0
 public void AddPerson(Person p)
 {
     using (var context = new SittingPlanContext())
     {
         context.People.Add(p);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void AddDesk(Desk d)
 {
     using (var context = new SittingPlanContext())
     {
         context.Desk.Add(d);
         context.SaveChanges();
     };
 }
Exemplo n.º 3
0
 public void AddChair(Chair c)
 {
     using (var context = new SittingPlanContext())
     {
         context.Chairs.Add(c);
         context.SaveChanges();
     };
 }
Exemplo n.º 4
0
        public List <Floor> GetPlan()
        {
            var floors = new List <Floor>();

            using (var Context = new SittingPlanContext())
            {
                floors = Context.Floors.Include(p => p.Desks.Select(x => x.Chairs.Select(y => y.Person))).ToList();
            }
            return(floors);
        }
Exemplo n.º 5
0
        public List <Floor> GetAll()
        {
            var floors = new List <Floor>();

            using (var Context = new SittingPlanContext())
            {
                floors = Context.Floors.Where(p => p.Id > 0).OrderBy(p => p.Id).ToList();
            }
            return(floors);
        }
Exemplo n.º 6
0
        public List <Desk> GetAll()
        {
            var desks = new List <Desk>();

            using (var sittingPlanContext = new SittingPlanContext())
            {
                desks = sittingPlanContext.Desk.Where(p => p.Id > 0).OrderBy(p => p.Name).ToList();
            }
            return(desks);
        }
Exemplo n.º 7
0
        public List <Chair> GetAll()
        {
            var chairs = new List <Chair>();

            using (var context = new SittingPlanContext())
            {
                chairs = context.Chairs.Where(x => x.Id > 0).Include(p => p.Person).OrderBy(x => x.Person.Id).ToList();
            }
            return(chairs);
        }
Exemplo n.º 8
0
        public List <Chair> GetChairs(int deskid)
        {
            var chairs = new List <Chair>();

            using (var context = new SittingPlanContext())
            {
                chairs = context.Chairs.Where(p => p.DeskId == deskid).Include(p => p.Person).OrderBy(p => p.Id).ToList();
            }
            return(chairs);
        }
Exemplo n.º 9
0
        public List <Person> GetAll()
        {
            var people = new List <Person>();

            using (var sittingPlanContext = new SittingPlanContext())
            {
                people = sittingPlanContext.People.Where(p => p.Id > 0).OrderBy(p => p.Name).ToList();
            }
            return(people);
        }
Exemplo n.º 10
0
 public void removePersontoChair(int chairid)
 {
     using (var context = new SittingPlanContext())
     {
         var chair = context.Chairs.Find(chairid);
         chair.PersonId = null;
         chair.Person   = null;
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        public List <Person> GetNotSittingPeople()
        {
            var people = new List <Person>();

            using (var context = new SittingPlanContext())
            {
                string query = "SELECT* FROM People P WHERE Id NOT IN(SELECT PersonId FROM Chairs C WHERE C.PersonId = P.Id)";
                people = context.Database.SqlQuery <Person>(query).ToList();
            }
            return(people);
        }
Exemplo n.º 12
0
 public void addPersontoChair(int personid, int chairid)
 {
     using (var context = new SittingPlanContext())
     {
         var chair  = context.Chairs.Find(chairid);
         var person = context.People.Find(personid);
         chair.PersonId = personid;
         chair.Person   = person;
         context.SaveChanges();
     }
 }
Exemplo n.º 13
0
        public void AddEmptyChair(int deskId)
        {
            var chair = new Chair();

            chair.DeskId = deskId;
            using (var context = new SittingPlanContext())
            {
                context.Chairs.Add(chair);
                context.SaveChanges();
            }
        }
Exemplo n.º 14
0
        public List <Person> AddPersonwithList(Person p)
        {
            var people = new List <Person>();

            using (var personContext = new SittingPlanContext())
            {
                personContext.People.Add(p);
                personContext.SaveChanges();
                people = personContext.People.Where(x => x.Id > 0).OrderBy(x => x.Name).ToList();
            }
            return(people);
        }
Exemplo n.º 15
0
        public void AddFloor(string name)
        {
            var floor = new Floor()
            {
                Name = name
            };

            using (var context = new SittingPlanContext())
            {
                context.Floors.Add(floor);
                context.SaveChanges();
            }
        }
Exemplo n.º 16
0
        public void AddDesk(string name, int floorid)
        {
            var desk = new Desk();

            desk.Name    = name;
            desk.FloorId = floorid;
            var floor = new Floor();

            using (var context = new SittingPlanContext())
            {
                context.Desk.Add(desk);
                context.SaveChanges();
            }
        }
Exemplo n.º 17
0
        public void AddPerson(string name, string surname, string mail)
        {
            var p = new Person()
            {
                Name    = name,
                Surname = surname,
                Mail    = mail
            };

            using (var context = new SittingPlanContext())
            {
                context.People.Add(p);
                context.SaveChanges();
            }
        }