Exemplo n.º 1
0
        public IActionResult AssignedCoursesToTeacher([FromBody] CourseViewModel course)
        {
            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();
            TeachersAssignedCourses   t  = new TeachersAssignedCourses();
            bool k = false;

            t.CourseId = db.Courses.Where(b => b.Name == course.name).FirstOrDefault().Id;
            t.UserId   = db.Users.Where(b => b.Email == course.email).FirstOrDefault().Id;
            foreach (TeachersAssignedCourses t1 in db.TeachersAssignedCourses)
            {
                if (t1.CourseId == t.CourseId && t1.UserId == t.UserId)
                {
                    k = true;
                    break;
                }
            }
            //Nullable<int> k = db.TeachersAssignedCourses.Where(p => p.UserId == t.UserId).FirstOrDefault().CourseId;
            if (k == false)
            {
                db.Add(t);
                db.SaveChanges();
                return(Ok());
            }
            else
            {
                ModelState.AddModelError("", "Course already assigned to this teacher");
                return(BadRequest(ModelState));
            }
        }
        public IActionResult Post([FromBody] CourseViewModel course)
        {
            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();
            CourseEnrollment          c  = new CourseEnrollment();

            c.CourseId         = db.Courses.Where(b => b.CourseCode == course.courseCode).FirstOrDefault().Id;
            c.UserId           = course.UserId;
            c.EnrollmentStatus = "Pending";
            db.Add(c);
            db.SaveChanges();
            return(Ok());
        }
Exemplo n.º 3
0
        public IActionResult Post([FromBody] GroupsPermissionsViewModel obj)
        {
            DigitalBoardMarkerContext db            = new DigitalBoardMarkerContext();
            List <string>             permissionLst = new List <string>();
            //permissionLst = obj.Name.Split(' ').ToList();
            UserGroups u = new UserGroups();

            u.Name        = obj.group;
            u.InstituteId = db.Users.Where(a => a.Email == obj.Email).SingleOrDefault().InstituteId;
            db.Add(u);
            db.SaveChanges();

            permissionLst = obj.Name.Split(' ').ToList();
            for (int i = 1; i < permissionLst.Count; i++)
            {
                GroupsAssignedPermissions p = new GroupsAssignedPermissions();
                p.PermissionId = db.PermissionLookup.Where(b => b.Name == permissionLst[i]).SingleOrDefault().Id;
                p.UserGroupId  = db.UserGroups.Where(b => b.Name == obj.group).SingleOrDefault().Id;
                db.Add(p);
            }
            db.SaveChanges();
            return(Ok());
        }
Exemplo n.º 4
0
        public void Post([FromBody] AssignmentsViewModel obj, int AssignmentId)
        {
            string tempFilePath = obj.FilePath;

            obj.FilePath = "Resources/SubmittedAssignments/";
            obj.FilePath = obj.FilePath + tempFilePath;
            var tempReg1 = obj.GroupRegNo[0];

            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();
            int GroupMembersCount        = obj.GroupRegNo.Count();


            StudentGroupNumber s = new StudentGroupNumber();

            db.StudentGroupNumber.Add(s);
            db.SaveChanges();
            int?groupId = db.StudentGroupNumber.Max(s1 => (int?)s1.Id);

            for (int i = 0; i < GroupMembersCount; i++)
            {
                StudentGroup sg = new StudentGroup();
                sg.Groupid = groupId;
                string tempReg = obj.GroupRegNo[i].ToString();
                sg.Userid = db.Users.Where(u => u.RegNo == tempReg).FirstOrDefault().Id;
                db.Add(sg);
            }

            AssignmentSubmission ass = new AssignmentSubmission();

            ass.SubmissionDateTime = obj.SubmissionDate;
            ass.StudentGroupid     = GroupMembersCount;
            ass.AssignmentFilePath = obj.FilePath;
            ass.AssignmentId       = AssignmentId;
            db.Add(ass);

            db.SaveChanges();
        }
Exemplo n.º 5
0
        public IActionResult Post([FromBody] LectureViewModel obj)
        {
            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();
            Lectures l = new Lectures();

            if (!db.Courses.Any(b => b.Id == obj.courseId))
            {
                ModelState.AddModelError("", "Course with course id doesn't exist");
                return(BadRequest(ModelState));
            }

            l.CourseId = obj.courseId;
            l.Name     = obj.Name;
            db.Add(l);
            db.SaveChanges();
            return(Ok());
        }
Exemplo n.º 6
0
        public IActionResult UploadLectureVideo([FromBody] LectureViewModel obj)
        {
            string tempFilePath = obj.FilePath;

            obj.FilePath = "Resources/Videos/";
            obj.FilePath = obj.FilePath + tempFilePath;
            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();
            Video v = new Video();

            v.CourseId      = obj.courseId;
            v.Titel         = obj.Name;
            v.Lectureid     = obj.LectureId;
            v.VideoFilePath = obj.FilePath;
            db.Add(v);
            db.SaveChanges();
            return(Ok());
        }
Exemplo n.º 7
0
        public IActionResult UploadLectureNotes([FromBody] LectureViewModel obj)
        {
            string tempFilePath = obj.FilePath;

            obj.FilePath = "Resources/Notes/";
            obj.FilePath = obj.FilePath + tempFilePath;
            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();
            Notes v = new Notes();

            v.CourseId  = obj.courseId;
            v.Title     = obj.Name;
            v.Lectureid = obj.LectureId;
            v.FilePath  = obj.FilePath;
            v.UpdatedBy = db.Users.Where(a => a.Email == obj.userId).FirstOrDefault().Id;
            v.CreatedBy = db.Users.Where(a => a.Email == obj.userId).FirstOrDefault().Id;
            v.UpdatedOn = DateTime.Now;
            v.CreatedOn = DateTime.Now;
            db.Add(v);
            db.SaveChanges();
            return(Ok());
        }
Exemplo n.º 8
0
        public IActionResult AssignGroups(AssignedGroupsViewModel obj)
        {
            List <string> UsersList = new List <string>();

            UsersList = obj.Users.Split(' ').ToList();
            DigitalBoardMarkerContext db = new DigitalBoardMarkerContext();

            for (int i = 1; i < UsersList.Count; i++)
            {
                UserAssignedGroups g = new UserAssignedGroups();
                g.UserId      = Convert.ToInt32(UsersList[i]);
                g.UserGroupId = db.UserGroups.Where(b => b.Name == obj.group).SingleOrDefault().Id;
                if (db.UserAssignedGroups.Any(b => b.UserId == g.UserId && b.UserGroupId == g.UserGroupId))
                {
                    ModelState.AddModelError("", "This User already assigned to that group");
                    break;
                }
                db.Add(g);
            }
            db.SaveChanges();
            return(Ok());
        }