Ejemplo n.º 1
0
        public bool StudentAddInGroup(int userId, int groupId)
        {
            StudentGroupDTO studentA = new StudentGroupDTO(1, userId, groupId);
            StudentGroup    student  = new StudentGroup();

            return(student.Add(studentA));
        }
Ejemplo n.º 2
0
        public void AddStudentGroup(int id, StudentGroupDTO group)
        {
            var groupFac = new StudentGroupFacade();

            using (var context = new AppDbContext())
            {
                var student = context.Users
                              .Include(s => s.StudentGroups)
                              .SingleOrDefault(s => s.Id == id);
                groupFac.CreateStudentGroup(group);


                StudentGroup grp;
                if (string.IsNullOrEmpty(group.Name))
                {
                    grp = context.StudentGroups.SingleOrDefault(g => g.RegId == group.RegId);
                }
                else
                {
                    grp = context.StudentGroups.SingleOrDefault(s => s.Name.Equals(group.Name));
                }

                if (student != null)
                {
                    student.StudentGroups.Add(grp);
                    grp.Students.Add(student);
                    context.Entry(grp).State     = EntityState.Modified;
                    context.Entry(student).State = EntityState.Modified;
                }


                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void AddStudentGroup(int testId, StudentGroupDTO group)
        {
            var groupFac = new StudentGroupFacade();

            using (var context = new AppDbContext())
            {
                var tt = context.TestTemplates
                         .Include(s => s.StudentGroups).Include(s => s.ThematicAreas)
                         .SingleOrDefault(s => s.Id == testId);


                groupFac.CreateStudentGroup(group);

                var grp = context.StudentGroups.SingleOrDefault(s => s.Name.Equals(group.Name));
                if (tt != null)
                {
                    tt.StudentGroups.Add(grp);
                    grp.Tests.Add(tt);
                    context.Entry(grp).State = EntityState.Modified;
                    context.Entry(tt).State  = EntityState.Modified;
                }


                context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
 public bool Add(StudentGroupDTO studentGroup)
 {
     using (IDbConnection connection = Connection.GetConnection())
     {
         string sqlExpression = "Student_Group_Add @UserID, @GroupID";
         return(connection.Query <bool>(sqlExpression, studentGroup).FirstOrDefault());
     }
 }
        public void DeleteStudentGroup(StudentGroupDTO studentGroup)
        {
            StudentGroup toDelete = Mapping.Mapper.Map <StudentGroup>(studentGroup);

            context.Database.Log          = Console.WriteLine;
            context.Entry(toDelete).State = EntityState.Deleted;
            context.SaveChanges();
        }
        public void CreateStudentGroup(StudentGroupDTO studentGroup)
        {
            StudentGroup newStudentGroup = Mapping.Mapper.Map <StudentGroup>(studentGroup);

            context.Database.Log = Console.WriteLine;
            context.StudentGroups.Add(newStudentGroup);
            context.SaveChanges();
        }
Ejemplo n.º 7
0
        public void DeleteStudentGroup(StudentGroupDTO studentGroup)
        {
            var newStudentGroup = Mapping.Mapper.Map <StudentGroup>(studentGroup);

            using (var context = new AppDbContext())
            {
                context.Entry(newStudentGroup).State = EntityState.Deleted;
                context.SaveChanges();
            };
        }
        public void EditStudentGroup(StudentGroupDTO studentGroup)
        {
            //var toEdit = Mapping.Mapper.Map<StudentGroup>(studentGroup);
            var toEdit = context.StudentGroups.Find(studentGroup.StudentGroupID);

            toEdit.Name           = studentGroup.Name;
            toEdit.RegistrateCode = studentGroup.RegistrateCode;

            context.Entry(toEdit).State = EntityState.Modified;
            context.SaveChanges();
        }
        public ActionResult Create(StudentGroupDTO group)
        {
            try
            {
                studentGroupFacade.CreateStudentGroup(group);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 10
0
        public void CreateStudentGroup(StudentGroupDTO studentGroup)
        {
            var newStudentGroup = Mapping.Mapper.Map <StudentGroup>(studentGroup);

            if (string.IsNullOrEmpty(studentGroup.Name))
            {
                return;
            }
            using (var context = new AppDbContext())
            {
                if (context.StudentGroups.SingleOrDefault(s => s.Name.Equals(studentGroup.Name)) != null)
                {
                    return;
                }
                if (context.StudentGroups.SingleOrDefault(s => s.RegId == studentGroup.RegId) != null)
                {
                    return;
                }
                context.StudentGroups.Add(newStudentGroup);
                context.SaveChanges();
            }
        }
Ejemplo n.º 11
0
 public void UpdateStudentGroup(StudentGroupDTO studentGroup, int[] selectedStudents)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            var themAreaFac = new ThematicAreaFacade();

            var questionFac = new QuestionFacade();
            var studgrpFac  = new StudentGroupFacade();
            var ansFac      = new AnswerFacade();
            var userFac     = new UserFacade();
            var testTempFac = new TestTemplateFacade();


            var que1 = new QuestionDTO()
            {
                Text = "EleGiggle"
            };
            var que2 = new QuestionDTO()
            {
                Text = "Keepo"
            };

            var pogChamp = new QuestionDTO()
            {
                Text = "Kappa"
            };
            var stud = new UserDTO
            {
                Email    = "[email protected]",
                Name     = "EleGiggle",
                Surname  = "FrankerZ",
                Password = "******",
                Code     = null,
                UserName = "******",
            };


//
//			var kappa = new StudentGroupDTO { Name = "StudGroup101" };
//			kappa.Students.Add(stud);
//
//			kappa.Tests.Add(new TestTemplateDTO {Name = "gachiGASM" , Date = DateTime.Now});
//			var test = new TestTemplateDTO {Name = "dasdaaaaaaaaa",Date = DateTime.Now };



            var roleManager = new AppRoleManager(new AppRoleStore(new AppDbContext()));

            if (!roleManager.RoleExists("admin"))
            {
                Console.WriteLine("admin role added");
                roleManager.Create(new AppRole {
                    Name = "admin"
                });
            }
            if (!roleManager.RoleExists("student"))
            {
                Console.WriteLine("student role added");

                roleManager.Create(new AppRole {
                    Name = "student"
                });
            }



            //			studgrpFac.CreateStudentGroup(kappa);
            //			questionFac.CreateManyQuestions(new List<QuestionDTO> { que1, que2, pogChamp }, "Twitch");


            //			userFac.Register(new UserDTO
            //						{
            //							Email = "*****@*****.**",
            //							Name = "Kapper",
            //							Surname = "PogChamp",
            //							Password = "******",
            //							Code = "Kappa",
            //							UserName = "******",
            //
            //						});
            //
            //
            var testTemp = new TestTemplateDTO
            {
                Name           = "MyFirstRealTest",
                CompletionTime = new TimeSpan(1, 1, 1),
                Date           = DateTime.Now,
                NumOfQuestions = 5,
                ThematicAreas  = new List <ThematicAreaDTO>
                {
                    new ThematicAreaDTO
                    {
                        Name = "Twitch"
                    }
                }
            };
            var studgrp = new StudentGroupDTO
            {
                Name  = "AllStudents",
                RegId = 420
            };
            //studgrpFac.CreateStudentGroup(studgrp);



//			foreach (var studentGroup in userFac.GetAllUsers())
//			{
//				Console.WriteLine(studentGroup.Name);
//			}



//			for (int i = 0; i < 10; i++)
//			{
//				var quest = new QuestionDTO
//				{
//					Answers = new List<AnswerDTO>
//				{
//					new AnswerDTO
//					{
//
//						Text = "C2 "+i,
//						Correct = true
//					},
//					new AnswerDTO
//					{
//						Text = "CC2"+i,
//						Correct = false
//					},
//					new AnswerDTO
//					{
//						Text = "CC3"+i,
//						Correct = false
//					}
//					,
//					new AnswerDTO
//					{
//						Text = "CC4 "+i,
//						Correct = false
//					}
//				}
//				,
//					Text = "C#2  Qnum =>"+i,
//					OneAnswer = true,
//					Points = 5
//				};
//
//				questionFac.CreateQuestion(quest, "C#2");
//			}

//			Console.WriteLine(testTempFac.CreateTestTemplate(new TestTemplateDTO
//			{
//				Name = "NewFag",NumOfQuestions = 5
//			}));
//
//			var quest=new QuestionDTO
//			{
//				Text = "AAAAAAAAAAAAAAA",
//
//				Points = 2,OneAnswer = true
//			};
//			int id =questionFac.CreateQuestion(quest,"Twitch");
//			var nuQ = questionFac.GetQuestionById(id);
//
//			questionFac.AddAnswerToQuestion(nuQ,new AnswerDTO
//			{
//				Text = "aaaaaaaaaaaaaaaaaaaaaaaaa"
//			});
//
//
//			var nuQ2 = questionFac.GetQuestionById(id);
//			Console.WriteLine("/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\");
//			foreach (var answer in nuQ2.Answers)
//			{
//				Console.WriteLine("ans ->"+answer.Text);
//			}



            //			var quest3 = questionFac.GetQuestionById(3);
            //
            //			 var ans = new AnswerDTO
            //			 {
            //				 Correct = true,
            //				 Description = " ayyy almao1",
            //				 Text = "TriHard",
            //				 Question = quest3
            //
            //			 };
            //			ansFac.CreateAnswer(ans);
            //
            //			ans = new AnswerDTO
            //			{
            //				Correct = true,
            //				Description = "Top KEK",
            //				Text = "4Head",
            //				Question = quest3
            //
            //			};
            //			ansFac.CreateAnswer(ans);
            //
            //
            //
            //
            //
            //			quest3 = questionFac.GetQuestionById(2);
            //
            //			ans = new AnswerDTO
            //			{
            //				Correct = true,
            //				Description = " ayyy almao2",
            //				Text = "haHAA",
            //				Question = quest3
            //
            //			};
            //			ansFac.CreateAnswer(ans);
            //
            //
            //
            //
            //			quest3 = questionFac.GetQuestionById(1);
            //
            //			ans = new AnswerDTO
            //			{
            //				Correct = true,
            //				Description = " ayyy almao3",
            //				Text = "KevinTurtle",
            //				Question = quest3
            //
            //			};
            //			ansFac.CreateAnswer(ans);
            //			testTempFac.CreateTestTemplate(testTemp);


            //testTempFac.AddTheme(testTemp,"LUL");

            //stud.StudentGroups.Add(kappa);
            //			studFac.CreateStudent(stud);
            //			teachFac.CreateTeacher(teacher);

            //			var test = kappa.Tests.First();
            //			test.Date=new DateTime(0);

            //


            //teachFac.DeleteTeacher(teacher);



            //			questionFac.RemoveAllQuestions();
            //			themAreaFac.RemoveAllThematicAreas();
            //			testTempFac.RemoveAllTestTemplates();



            //						testTempFac.CreateTestTemplate(test);

            /*
             *                      themAreaFac.CreateThematicArea("forsenW");
             *
             *                      themAreaFac.CreateThematicArea("forsenK");
             *                      themAreaFac.CreateThematicArea("forsenC");
             *
             *
             *                      questionFac.CreateQuestion(que1,"forsenW");
             *                      questionFac.CreateQuestion(que2, "forsenW");
             *                      questionFac.CreateQuestion(pogChamp, "ForsenC");
             */
            //Console.WriteLine(questionFac.GetQuestionById(1).ThematicArea.Name+" kappa"+questionFac.GetQuestionById(1).Id);

            //studgrpFac.CreateStudentGroup(kappa);

//			var tt=new TestTemplateDTO
//			{
//				Name = "asdfa",
//				NumOfQuestions = 5,
//				ThematicAreas = new List<ThematicAreaDTO>
//				{
//					new ThematicAreaDTO
//					{
//						Name = "Twitch"
//					},
//					new ThematicAreaDTO
//					{
//						Name = "forsen"
//					},
//					new ThematicAreaDTO
//					{
//						Name="Billy"
//					}
//				}
//			};
//			int id =testTempFac.CreateTestTemplate(tt);
//
//			Console.WriteLine("after create");
//			foreach (var dto in testTempFac.GetTestTemplateById(id).StudentGroups)
//			{
//				Console.WriteLine(dto.Name);
//			}
//
//			testTempFac.AddStudentGroup(id,new StudentGroupDTO
//			{
//				Name = "blaze it",
//				RegId = 13
//			});
//			Console.WriteLine("after update");
//
//			foreach (var dto in testTempFac.GetTestTemplateById(id).StudentGroups)
//			{
//				Console.WriteLine(dto.Name);
//
//			}



            //			var tt2 = testTempFac.GetTemplateByName(tt.Name);
            //
            //
            //			Console.WriteLine("///////////");
            //			tt2.ThematicAreas.Add(new ThematicAreaDTO
            //			{
            //				Name = "Billy"
            //			});
            //
            //			testTempFac.UpdateTestTemplate(tt2);


            var themAreas = themAreaFac.GetAllThematicAreas();
            var questions = questionFac.GetAllQuestions();
            var studGrp   = studgrpFac.GetAllStudentGroups();


            var allTests = testTempFac.GetAllTestTemplates();



            //			var qs = questionFac.GetNumOfRandQuestionsFromThematicAreas(5, testTemp.ThematicAreas);
            //			foreach (var q in qs)
            //			{
            //				Console.WriteLine(q.Text);
            //
            //			}


//			foreach (var i in testTempFac.GetAllTestTemplates())
//			{
//				Console.WriteLine("testTemp name :" + i.Name);
//				foreach (var thematicAreaDto in i.ThematicAreas)
//				{
//					Console.WriteLine(thematicAreaDto.Name);
//				}
//			}

            Console.WriteLine("////////////////////////////");

//			Console.WriteLine("Stávající theme areas:");
//			foreach (var item in themAreas)
//			{
//				Console.WriteLine("   {0}  countQ:{1}", item.Name, item.Questions.Count);
//
//				foreach (var q in item.Questions)
//				{
//					Console.WriteLine("     "+q.Text);
//				}
//			}
//			Console.WriteLine("questions:");
//			foreach (var q in questions)
//			{
//				Console.WriteLine(@"   {0} area:{1}", q.Text, q.ThematicArea.Name);
//			}
//			Console.WriteLine("studgroups:");
//
//
//			foreach (var q in studGrp)
//			{
//				Console.WriteLine($"   studgrp name{ q.Name} ");
//
//				Console.WriteLine("      studs ");
//				foreach (var st in q.Students)
//				{
//					Console.WriteLine("        " + st.Name);
//				}
//
//				Console.WriteLine("      tests ");
//				foreach (var st in q.Tests)
//				{
//					Console.WriteLine("        " + st.Name +"  DATE FAGGOTINA   "+ st.Date);
//					Console.WriteLine("kapaaaa");
//				}
//			}
//
//
//
//
//
//			Console.WriteLine(" studs :");
//
//
//
//
//
//
//			Console.WriteLine(" testTemps :");
//			foreach (var q in allTests)
//			{
//				Console.WriteLine($"   testTemp name{ q.Name} " + "  DATE FAGGOTINA   " + q.Date);
//
//
//
//				Console.WriteLine("      themAreas ");
//				foreach (var st in q.ThematicAreas)
//				{
//					Console.WriteLine("        " + st.Name);
//				}
//			}
//
//
            Console.WriteLine("all done");
            Console.ReadKey();
        }
Ejemplo n.º 13
0
        public int StudentDeleteFromGroup(StudentGroupDTO studentD)
        {
            StudentGroup student = new StudentGroup();

            return(student.Delete(studentD.ID));
        }