public bool addInscription(Inscription inscription)
 {
     try
     {
         _context.Inscription.Add(inscription);
         _context.SaveChanges();
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        public bool AddSubject(string Label)
        {
            Subject subject = new Subject();

            subject.Label = Label;
            try
            {
                _context.Subject.Add(subject);
                _context.SaveChanges();
            }
            catch { return(false); }
            return(true);
        }
        public bool CompleteModule(int idModule, int idUser)
        {
            Completed completed = new Completed();

            completed.IdModule = idModule;
            completed.IdUser   = idUser;
            try
            {
                _context.Completed.Add(completed);
                _context.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        public CoursesData(ELearningPlatformContext context)
        {
            _context = context;

            if (_context.Course.Count() == 0)
            {
                // Create a new User if collection is empty,
                // which means you can't delete all users.
                _context.Course.AddRange(new Course {
                    Name = "Test", Desc = "Test course", CreationDate = DateTime.Now, Ico = "./img/Ico/16.jpg", IdInstructor = 11, IdSubject = 1
                }, new Course {
                    Name = "Test2", Desc = "Test course", CreationDate = DateTime.Now, Ico = "./img/Ico/16.jpg", IdInstructor = 11, IdSubject = 1
                }, new Course {
                    Name = "Test3", Desc = "Test course", CreationDate = DateTime.Now, Ico = "./img/Ico/16.jpg", IdInstructor = 11, IdSubject = 1
                });
            }
            if (_context.Inscription.Count() == 0)
            {
                _context.Inscription.Add(new Inscription {
                    IdCourse = 8, IdUser = 11
                });
            }
            _context.SaveChanges();
        }