public IActionResult Index()
        {
            CoursesVM model = new CoursesVM()
            {
                Background = _db.Backgrounds.FirstOrDefault()
            };

            return(View(model));
        }
        public async Task <IActionResult> Message(CoursesVM coursesVM, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }
            Message message = coursesVM.Message;

            _db.Messages.Add(message);
            await _db.SaveChangesAsync();

            return(LocalRedirect(returnUrl));
        }
        // GET: AttendanceStudent
        public async Task <ActionResult> ViewAttendance(int id = -1)
        {
            List <AllStudentCourses>        checkAttendance          = new List <AllStudentCourses>();
            List <StudentCoursesAttendance> studentCourseAttendances = new List <StudentCoursesAttendance>().OrderBy(x => x.AttendanceID).ToList();

            //StudentCourseAttendance studentCourseAttendance = new StudentCourseAttendance();
            CoursesVM courseVM = new CoursesVM();

            using (var client = new HttpClient())
            {
                int studentId = 10; // student login id

                client.BaseAddress = new Uri("https://localhost:44380/api/");
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                //HTTP GET
                HttpResponseMessage result = await client.GetAsync("AttendanceStudent/GetStudentCourse/" + studentId);

                if (result.IsSuccessStatusCode)
                {
                    var response = result.Content.ReadAsStringAsync().Result;
                    // var re = r.Content.ReadAsStringAsync().Result;
                    checkAttendance = JsonConvert.DeserializeObject <List <AllStudentCourses> >(response);
                }
                courseVM.allStudentCourses        = checkAttendance;
                courseVM.studentcourseattendances = new List <StudentCoursesAttendance>();
                if (id == -1)
                {
                    return(View(courseVM));
                }

                int courseid = id;
                //karna hai sahi
                HttpResponseMessage result2 = await client.GetAsync("AttendanceStudent/GetStudentAttendance/" + courseid);

                if (result2.IsSuccessStatusCode)
                {
                    var response = result2.Content.ReadAsStringAsync().Result;
                    // var re = r.Content.ReadAsStringAsync().Result;
                    studentCourseAttendances = JsonConvert.DeserializeObject <List <StudentCoursesAttendance> >(response);
                }

                courseVM.studentcourseattendances = studentCourseAttendances;
                //studentCourseAttendance.CourseCode = checkAttendance;

                return(View(courseVM));
            }
        }
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Course course = await _db.Courses.FindAsync(id);

            if (course == null)
            {
                return(NotFound());
            }
            CoursesVM model = new CoursesVM()
            {
                Course = _db.Courses.Include(c => c.CourseDetail).Include(c => c.CourseFeature).FirstOrDefault(c => c.Id == id)
            };

            return(View(model));
        }
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Course course = await _db.Courses.FindAsync(id);

            if (course == null)
            {
                return(NotFound());
            }

            CoursesVM model = new CoursesVM()
            {
                Background = _db.Backgrounds.FirstOrDefault(),
                Course     = _db.Courses.Include(c => c.CourseDetail).Include(c => c.CourseFeature).FirstOrDefault(c => c.Id == id),
                Courses    = _db.Courses.Take(6),
                SideBlogs  = _db.Blogs.OrderByDescending(b => b.Id).Take(3)
            };

            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Course(int id)
        {
            CoursesVM model = instructorBL.LoadInstructorCourses(id);

            return(View(model));
        }