Exemple #1
0
        public async Task <IActionResult> Details(int id, [Bind("Id,IsEnabled,TopicNumber,Notes,ModuleId,Summary,Title,DateCreated,UserCreated,DateModified,UserModified,VideoUrl")] AdmTopic admTopic, List <IFormFile> files)
        {
            if (id != admTopic.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (files != null && files.Count > 0)
                    {
                        string folderName  = "Upload";
                        string webRootPath = _hostingEnvironment.WebRootPath;
                        string newPath     = Path.Combine(webRootPath, folderName);
                        if (!Directory.Exists(newPath))
                        {
                            Directory.CreateDirectory(newPath);
                        }
                        foreach (IFormFile item in files)
                        {
                            if (item.Length > 0)
                            {
                                string fileName = ContentDispositionHeaderValue.Parse(item.ContentDisposition).FileName.Trim('"');
                                string fullPath = Path.Combine(newPath, fileName);
                                using (var stream = new FileStream(fullPath, FileMode.Create))
                                {
                                    item.CopyTo(stream);
                                }
                            }
                        }

                        _context.Update(admTopic);
                        await _context.SaveChangesAsync();

                        return(this.Content("Success"));
                    }
                    return(this.Content("Fail"));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdmTopicExists(admTopic.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            ViewData["ModuleId"] = new SelectList(_context.AdmModules, "ModuleId", "Title", admTopic.ModuleId);
            return(View(admTopic));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ResultId,StudentName,ExamName,Course,TotalQuestions,Attempted,NotAttempted,Correct,InCorrect,Score")] AdmResult admResult)
        {
            if (id != admResult.ResultId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(admResult);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdmResultExists(admResult.ResultId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(admResult));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ExaminationId,Id,IsActive,Title,QuestionNo,Instructions")] ExamSetUp examSetUp)
        {
            if (id != examSetUp.ExaminationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(examSetUp);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExamSetUpExists(examSetUp.ExaminationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.AdmClass, "Id", "ClassName", examSetUp.Id);
            return(View(examSetUp));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ClassName,CourseId,StartDate,EndDate,IsActive,DateCreated,UserCreated,DateModified,UserModified")] AdmClass admClass)
        {
            if (id != admClass.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(admClass);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdmClassExists(admClass.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.AdmCourses, "CourseId", "CourseTitle", admClass.CourseId);
            return(View(admClass));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,InstructorId,CourseId,DateCreated,UserCreated,DateModified,UserModified")] InstructorCourse instructorCourse)
        {
            if (id != instructorCourse.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructorCourse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorCourseExists(instructorCourse.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]     = new SelectList(_context.AdmCourses, "CourseId", "CourseTitle", instructorCourse.CourseId);
            ViewData["InstructorId"] = new SelectList(_context.Instructor, "InstructorId", "FullName", instructorCourse.InstructorId);
            return(View(instructorCourse));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ModuleId,Description,IsEnabled,CourseId,ModuleCode,Title,DateCreated,UserCreated,DateModified,UserModified")] AdmModules admModules)
        {
            if (id != admModules.ModuleId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(admModules);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdmModulesExists(admModules.ModuleId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                await Task.Delay(1500);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.AdmCourses, "CourseId", "CourseTitle", admModules.CourseId);
            return(View(admModules));
        }
        public async Task <IActionResult> Edit(int id, [Bind("QuestId,CourseId,ModuleId,Instructions,Question,Option1,Option2,Option3,Option4,RightAnswer")] Questions questions)
        {
            if (id != questions.QuestId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(questions);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuestionsExists(questions.QuestId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"] = new SelectList(_context.AdmCourses, "CourseId", "CourseTitle", questions.CourseId);
            ViewData["ModuleId"] = new SelectList(_context.AdmModules, "Title", "Title", questions.ModuleId);
            return(View(questions));
        }
Exemple #8
0
        public async Task <IActionResult> Edit(int id, [Bind("BlogId,Title,ShortDescription,Content,Meta,DateCreated,UserCreated,DateModified,UserModified")] Blog blog)
        {
            if (id != blog.BlogId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.BlogId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
        public async Task <IActionResult> Edit(int id, [Bind("InstructorId,FirstName,SurName,OtherNames,PreferedName,InstructorEmail,PhoneNumber,Country,DateCreated,UserCreated,DateModified,UserModified")] Instructor instructor)
        {
            if (id != instructor.InstructorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructor.InstructorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(instructor));
        }
Exemple #10
0
        public async Task <IActionResult> Edit(int id, [Bind("AssignmentId,Description,IsEnabled,Title,Id,DateCreated,UserCreated,DateModified,UserModified")] AdmAssignment admAssignment)
        {
            if (id != admAssignment.AssignmentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(admAssignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdmAssignmentExists(admAssignment.AssignmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.AdmClass, "Id", "ClassName", admAssignment.Id);
            return(View(admAssignment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,IsApproved,IsCompleted,StudentId,CourseId,ApprovedDate,DateCreated,UserCreated,DateModified,UserModified")] StCourseEnrollment stCourseEnrollment)
        {
            if (id != stCourseEnrollment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stCourseEnrollment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StCourseEnrollmentExists(stCourseEnrollment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.AdmCourses, "CourseId", "CourseId", stCourseEnrollment.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "StudentId", "StudentFirstName", stCourseEnrollment.StudentId);
            return(View(stCourseEnrollment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CourseId,CourseCode,IsEnabled,CourseTitle,VideoUrl,Description,DateCreated,UserCreated,DateModified,UserModified")] AdmCourses admCourses)
        {
            if (id != admCourses.CourseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(admCourses);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdmCoursesExists(admCourses.CourseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(admCourses));
        }