public ActionResult Presence(int subjectId) { // Get the specified subject. var subject = _subjectRepository.GetById(subjectId); if (subject == null) { return(HttpNotFound()); } // Get the current presence. int studentId = Student.Id; var presence = _presenceRepository.GetByStudent(studentId); // Map the subject to a view model. var subjectModel = Mapper.Map <SubjectModel>(subject); // Create the presence view model. var presenceModel = new PresenceModel { Subject = subjectModel, // Check if student is already present. AlreadyPresent = presence.Any(p => p.IsPresent(subjectId, studentId)), PastSubject = subject.IsPastSubject() }; return(View(presenceModel)); }
public ActionResult Create(PresenceModel vm) { if (WebUser != null) { // Create the batch operation. var batchOperation = new TableBatchOperation(); var userActivities = JsonConvert.DeserializeObject <List <UserActivity> >(vm.Payload); var service = new CloudTableService(); foreach (var userActivity in userActivities) { userActivity.PartitionKey = WebUser.Id.ToString(); userActivity.RowKey = Guid.NewGuid().ToString("N"); userActivity.AssetId = vm.AssetId; userActivity.Name = WebUser.Name; batchOperation.Insert(userActivity); } if (userActivities.Count > 0) { service.AddBatch(batchOperation); } return(Json(true)); } return(Json(false)); }
internal DiscordPresence(PresenceModel model) { User = new DiscordUser(model.User); GuildId = model.GuildId; RoleIds = model.Roles; if (model.Game != null) { Game = new DiscordActivity(model.Game); } Status = model.Status; Activities = model.Activities?.Select(x => new DiscordActivity(x)).ToArray(); if (model.ClientStatus != null) { ClientStatus = new DiscordClientStatus(model.ClientStatus); } PremiumSince = model.PremiumSince; Nick = model.Nick; }
public FakeLibrusManager() { this.classes.Add(new ClassModel("IA")); this.classes.Add(new ClassModel("IB")); this.classes.Add(new ClassModel("IC")); var clazz = this.GetClassById("IA"); this.students.Add(new StudentModel(1, "Aneta", "Dams", clazz, true)); this.students.Add(new StudentModel(2, "Karolina", "Kowalska", clazz, true)); this.students.Add(new StudentModel(3, "Anna", "Nowak", clazz, true)); this.students.Add(new StudentModel(4, "Mateusz", "Brzeziński", clazz, false)); this.students.Add(new StudentModel(5, "Justyna", "Karpińska", clazz, true)); var clazz1 = this.GetClassById("IB"); this.students.Add(new StudentModel(6, "Maciej", "Sikorski", clazz1, false)); this.students.Add(new StudentModel(7, "Paweł", "Nowakowski", clazz1, false)); this.students.Add(new StudentModel(8, "Adrian", "Rydzyński", clazz1, false)); this.students.Add(new StudentModel(9, "Monika", "Kwiatkowska", clazz1, true)); var clazz2 = this.GetClassById("IC"); this.students.Add(new StudentModel(10, "Anna", "Mrozowska", clazz2, true)); this.students.Add(new StudentModel(11, "Kamila", "Boruta", clazz2, true)); this.students.Add(new StudentModel(12, "Andrzej", "Gutowski", clazz2, false)); this.students.Add(new StudentModel(13, "Szymon", "Kołodziej", clazz2, false)); this.subjects.Add(new SubjectModel("AM", "Analiza Matematyczna")); this.subjects.Add(new SubjectModel("MD", "Matematyka Dyskretna")); this.subjects.Add(new SubjectModel("AiSD", "Algorytmy i struktury danych")); this.subjects.Add(new SubjectModel("SO", "Systemy Operacyjne")); this.subjects.Add(new SubjectModel("PI", "Programowanie I (C++)")); this.subjects.Add(new SubjectModel("AL", "Algebra Liniowa")); this.subjects.Add(new SubjectModel("SOS", "Środowisko Obliczeń Symblicznych")); this.subjects.Add(new SubjectModel("TJF", "Teoria Języków Formalnych")); this.subjects.Add(new SubjectModel("PII", "Programowanie II (C#)")); this.subjects.Add(new SubjectModel("PB", "Projekt Bazodanowy")); this.subjects.Add(new SubjectModel("LG", "Laboratorium Grafiki")); this.subjects.Add(new SubjectModel("PIII", "Programowanie III (Java)")); this.subjects.Add(new SubjectModel("TO", "Teoria Obliczalności")); int id = 0; Random gen = new Random(); id++; var date = "środa"; var table = new TimeTableModel(id, date, this.GetClassById("IA"), this.GetSubjectById("AM")); this.timeTables.Add(table); var start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IB"), this.GetSubjectById("AiSD")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IC"), this.GetSubjectById("AL")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IA"), this.GetSubjectById("MD")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IB"), this.GetSubjectById("SO")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IC"), this.GetSubjectById("SOS")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IA"), this.GetSubjectById("SO")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IB"), this.GetSubjectById("TJF")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date, this.GetClassById("IC"), this.GetSubjectById("PB")); this.timeTables.Add(table); start = new DateTime(2014, 10, 1, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; var date1 = "czwartek"; table = new TimeTableModel(id, date1, this.GetClassById("IA"), this.GetSubjectById("PI")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IB"), this.GetSubjectById("PII")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IC"), this.GetSubjectById("AiSD")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IA"), this.GetSubjectById("AL")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IB"), this.GetSubjectById("PB")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IC"), this.GetSubjectById("PI")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IA"), this.GetSubjectById("PB")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IB"), this.GetSubjectById("SOS")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date1, this.GetClassById("IC"), this.GetSubjectById("AM")); this.timeTables.Add(table); start = new DateTime(2014, 10, 2, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; var date2 = "piątek"; table = new TimeTableModel(id, date2, this.GetClassById("IA"), this.GetSubjectById("AiSD")); this.timeTables.Add(table); start = new DateTime(2014, 10, 3, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date2, this.GetClassById("IB"), this.GetSubjectById("PI")); this.timeTables.Add(table); start = new DateTime(2014, 10, 3, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date2, this.GetClassById("IC"), this.GetSubjectById("PIII")); this.timeTables.Add(table); start = new DateTime(2014, 10, 3, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date2, this.GetClassById("IA"), this.GetSubjectById("TJF")); this.timeTables.Add(table); start = new DateTime(2014, 10, 3, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date2, this.GetClassById("IB"), this.GetSubjectById("AM")); this.timeTables.Add(table); start = new DateTime(2014, 10, 3, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date2, this.GetClassById("IC"), this.GetSubjectById("LG")); this.timeTables.Add(table); start = new DateTime(2014, 10, 3, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; id++; var date3 = "poniedziałek"; table = new TimeTableModel(id, date3, this.GetClassById("IA"), this.GetSubjectById("LG")); this.timeTables.Add(table); start = new DateTime(2014, 10, 6, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date3, this.GetClassById("IB"), this.GetSubjectById("AL")); this.timeTables.Add(table); start = new DateTime(2014, 10, 6, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date3, this.GetClassById("IC"), this.GetSubjectById("MD")); this.timeTables.Add(table); start = new DateTime(2014, 10, 6, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date3, this.GetClassById("IA"), this.GetSubjectById("PIII")); this.timeTables.Add(table); start = new DateTime(2014, 10, 6, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date3, this.GetClassById("IB"), this.GetSubjectById("TO")); this.timeTables.Add(table); start = new DateTime(2014, 10, 6, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date3, this.GetClassById("IC"), this.GetSubjectById("SO")); this.timeTables.Add(table); start = new DateTime(2014, 10, 6, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; id++; var date4 = "wtorek"; table = new TimeTableModel(id, date4, this.GetClassById("IA"), this.GetSubjectById("TO")); this.timeTables.Add(table); start = new DateTime(2014, 10, 7, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date4, this.GetClassById("IB"), this.GetSubjectById("PIII")); this.timeTables.Add(table); start = new DateTime(2014, 10, 7, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date4, this.GetClassById("IC"), this.GetSubjectById("LG")); this.timeTables.Add(table); start = new DateTime(2014, 10, 7, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date4, this.GetClassById("IA"), this.GetSubjectById("SOS")); this.timeTables.Add(table); start = new DateTime(2014, 10, 7, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IA")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date4, this.GetClassById("IB"), this.GetSubjectById("LG")); this.timeTables.Add(table); start = new DateTime(2014, 10, 7, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IB")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } id++; table = new TimeTableModel(id, date4, this.GetClassById("IC"), this.GetSubjectById("TO")); this.timeTables.Add(table); start = new DateTime(2014, 10, 7, 8, 0, 0).Date; for (int t = 0; t < 9; t++) { var d = start.AddDays(7 * t); foreach (StudentModel student in this.GetStudentsByClass("IC")) { PresenceModel pre = new PresenceModel(student, table.Subject, d, null); int prob = gen.Next(100); if (prob < 80) { pre.Present = true; } else { pre.Present = false; } this.presences.Add(pre); } } }