Пример #1
0
        protected override void Seed(GradeContext context)
        {
            var students = new List <Student>();
            var subjects = new List <Subject>();

            students.Add(new Student("Student1"));
            students.Add(new Student("Student2"));
            students.Add(new Student("Student3"));
            students.Add(new Student("Student4"));
            students.Add(new Student("Student5"));

            subjects.Add(new Subject("Subject1"));
            subjects.Add(new Subject("Subject2"));
            subjects.Add(new Subject("Subject3"));
            subjects.Add(new Subject("Subject4"));
            subjects.Add(new Subject("Subject5"));

            foreach (Student student in students)
            {
                context.Students.Add(student);
            }

            foreach (Subject subject in subjects)
            {
                context.Subjects.Add(subject);
            }

            base.Seed(context);
        }
Пример #2
0
 //Constructor
 public SectionsController(SectionContext context, StudentContext studContext, GradeContext gradeContext, EventContext eventContext)     //<---------------added formal parameter for studentContext injection
 {
     _context      = context;
     _studContext  = studContext;    //<---------------added injection (Lower 3)
     _gradeContext = gradeContext;
     _eventContext = eventContext;
 }
Пример #3
0
 public HomeController(EventContext ec, GradeContext gc, StudentContext sc, SectionContext ssc)
 {
     _context        = ec;
     _gradeContext   = gc;
     _studentContext = sc;
     _sectionContext = ssc;
     grid            = new ClassroomGrid();
 }
        public GradeController(GradeContext context)
        {
            _context = context;

            if (_context.GradeItems.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.GradeItems.Add(new GradeItem {
                    Name = "Programação Orientada a Objetos I", Codigo = "GSI009", Horario = "20:50 - 22:30", IsAttended = true, Periodo = 5
                });
                _context.SaveChanges();
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            string path = @"C:\Users\ladob\Desktop\testt.txt";

            path = @path;

            var records = new List <Grade>();

            if (File.Exists(path))
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    string headerLine = sr.ReadLine();
                    string line;


                    while ((line = sr.ReadLine()) != null)
                    {
                        line = line.Trim();

                        var recs = line.Split(',');

                        var x = new Grade()
                        {
                            StudentId = int.Parse(recs[0]),
                            SubjectId = int.Parse(recs[1]),
                            Points    = int.Parse(recs[2])
                        };

                        using (var context = new GradeContext())
                        {
                            context.Entry(x).State = EntityState.Added;

                            context.SaveChanges();
                        }
                    }
                }
            }
        }
Пример #6
0
 public GradesController(GradeContext context)
 {
     _context = context;
 }
Пример #7
0
        private static void AddAssignment(Student std)
        {
            //bool continueEntering = true;
            bool invalidType  = true;
            bool invalidClass = true;
            bool invalidGrade = true;
            int  type         = 1;
            //string asgType ;
            int    cls;
            Grade  grade = Grade.None;
            int    grd;
            string title;
            Class  classType = Class.None;


            while (invalidType)
            {
                Console.WriteLine("Enter 1 to enter A new Homework Assignment ");
                Console.WriteLine("Enter 2 to enter A new Test Assignment");
                try
                {
                    type = int.Parse(Console.ReadLine());
                    if (type == 1 || type == 2)
                    {
                        invalidType = false;
                        //if (type == 1)
                        //{
                        //    asgType = "Homework";
                        //}

                        //if (type == 2)
                        //{
                        //    asgType = "Test";
                        //}
                    }
                    else
                    {
                        Console.WriteLine("Invalid Entry");
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine("Enter Assignment Title");
            title = Console.ReadLine();

            while (invalidClass)
            {
                Console.WriteLine("Enter 1 To Enter A Math Assignment ");
                Console.WriteLine("Enter 2 To Enter A English Assignment ");
                Console.WriteLine("Enter 3 To Enter A Science Assignment ");
                Console.WriteLine("Enter 4 To Enter A Computer Science Assignment ");
                Console.WriteLine("Enter 5 To Enter A History Assignment ");
                try
                {
                    cls = int.Parse(Console.ReadLine());

                    // controls whether the loops continues or stops
                    if (cls > 5 || cls < 1)
                    {
                        Console.WriteLine("Invalid Entry ");
                        continue;
                    }
                    else
                    {
                        invalidClass = false;
                    }

                    switch (cls)
                    {
                    case 1:
                        classType = Class.Math;
                        break;

                    case 2:
                        classType = Class.English;
                        break;

                    case 3:
                        classType = Class.Science;
                        break;

                    case 4:
                        classType = Class.ComputerScience;
                        break;

                    case 5:
                        classType = Class.History;
                        break;

                    default:
                        invalidClass = true;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            while (invalidGrade)
            {
                Console.WriteLine("Enter 1 to Give Grade of 'A' ");
                Console.WriteLine("Enter 2 to Give Grade of 'B' ");
                Console.WriteLine("Enter 3 to Give Grade of 'C' ");
                Console.WriteLine("Enter 4 to Give Grade of 'D' ");
                Console.WriteLine("Enter 5 to Give Grade of 'F' ");
                try
                {
                    grd = int.Parse(Console.ReadLine());

                    if (grd > 5 || grd < 1)
                    {
                        Console.WriteLine("Invalid Entry");
                        continue;
                    }
                    else
                    {
                        invalidGrade = false;
                    }


                    switch (grd)
                    {
                    case 1:
                        grade = Grade.A;
                        break;

                    case 2:
                        grade = Grade.B;
                        break;

                    case 3:
                        grade = Grade.C;
                        break;

                    case 4:
                        grade = Grade.D;
                        break;

                    case 5:
                        grade = Grade.F;
                        break;

                    default:
                        grade        = Grade.F;
                        invalidClass = true;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.InnerException);
                }
            }

            if (type == 1)
            {
                var assignment = new Homework(grade, title, classType, std);
                using (var context = new GradeContext())
                {
                    context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Students] ON");
                    context.Homeworks.Add(assignment);
                    context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Students] OFF");
                    context.SaveChanges();
                }

                Console.WriteLine("Assignment Added Successfully");
            }
            else
            {
                var assignment = new Test(grade, title, classType, std);
                using (var context = new GradeContext())
                {
                    try
                    {
                        context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Students] ON");
                        context.Tests.Add(assignment);
                        context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[Students] OFF");
                        context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.InnerException);
                    }
                }
                Console.WriteLine("Assignment Added Successfully");
            }

            Console.WriteLine("");
            Console.WriteLine("Enter 1 To Add Another Grade ");
            Console.WriteLine("Enter Any Key To Exit ");


            try
            {
                var input = int.Parse(Console.ReadLine());

                if (input == 1)
                {
                    AddAssignmentMenu();
                }
            }catch (Exception ex)
            {
            }
        }
Пример #8
0
 public GradeController(GradeContext gradeContext, IGradeService gradeService, IMapper mapper)
 {
     _gradeContext = gradeContext;
     _gradeService = gradeService;
     _mapper       = mapper;
 }
Пример #9
0
 public CoursesController(GradeContext db)
 {
     _db = db;
 }
Пример #10
0
 public GradeService(GradeContext gradeContext, SubjectContext subjectContext, StudentContext studentContext)
 {
     _gradeContext   = gradeContext;
     _subjectContext = subjectContext;
     _studentContext = studentContext;
 }
Пример #11
0
 public StudentsController(GradeContext db)
 {
     _db = db;
 }