public static int GetNumberEmployeeWithRDV() { using (var context = new AppointmentContext()) { var numberOfEmployeeRDV = (from p in context.People where p.IsEmployee == true && p.Agenda.Count > 0 select p).Count(); return(numberOfEmployeeRDV); } }
public static int GetPastAppointmentByRoom(Room desiredRoom) { using (var context = new AppointmentContext()) { var numberOfFutureAppointment = (from appt in context.Appointments join r in context.Rooms on appt.Room.RoomID equals r.RoomID where appt.Room == desiredRoom && appt.EndDate < DateTime.Now select appt).Count(); return(numberOfFutureAppointment); } }
public static int GetFuturRdvByEmployee(Person employee) { using (var context = new AppointmentContext()) { var countOfFuturRdv = (from appt in context.Appointments join pers in context.People on appt.Person.PersonID equals pers.PersonID where pers.IsEmployee == true && appt.StartDate > DateTime.Now && appt.Person == employee select appt).Count(); return(countOfFuturRdv); } }
public static void GetRDVByStructure() { using (var context = new AppointmentContext()) { //Le nombre de rendez-vous appointmentspar structure //SELECT * FROM APPT INNER JOIN ROOM OINNER JOIN STRUCTURE GROUP BY STRUCTURE var rdbByStruct = from appt in context.Appointments join r in context.Rooms on appt.Room.RoomID equals r.RoomID join s in context.Structures on r.Structure.StructureID equals s.StructureID select s; //group s by s.StructureID; foreach (var current in rdbByStruct) { Console.WriteLine(current.StructureID); } } }
static void Main(string[] args) { using (var context = new AppointmentContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var address1 = new Address { StreetName = "Baker Street", StreetNumber = 221, Zipcode = 22345 }; var address2 = new Address { StreetName = "Wolf Street", StreetNumber = 36, Zipcode = 1983 }; var address3 = new Address { StreetName = "Inanc Street", StreetNumber = 25, Zipcode = 1995 }; var structure1 = new Structure { Address = address1 }; var structure2 = new Structure { Address = address2 }; var structure3 = new Structure { Address = address3 }; List <Structure> structureList = new List <Structure> { structure1, structure2, structure3 }; foreach (Structure currentStructure in structureList) { currentStructure.RoomList = GenerateRoom(currentStructure, 3); currentStructure.PersonList = GeneratePerson(currentStructure, 5); foreach (Room currentRoom in currentStructure.RoomList) { currentRoom.AppointmentList = GenerateFuturAppointment(currentRoom, 5); currentRoom.AppointmentList.AddRange(GeneratePastAppointment(currentRoom, 5)); } foreach (Person currentPerson in currentStructure.PersonList) { currentPerson.Agenda = GetRandomRDV(currentStructure); } } context.AddRange(structureList); context.SaveChanges(); //StatisticCalculator.GetPastAppointmentByRoom(structure1.RoomList[0]); Console.WriteLine(StatisticCalculator.GetFuturRdvByEmployee(structure1.PersonList[0])); } //Console.WriteLine("Nombre d'employés ayant eu ou allant avoir un rendez-vous : "); //Console.WriteLine(StatisticCalculator.GetNumberEmployeeWithRDV()); StatisticCalculator.GetRDVByStructure(); }