Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (User.Identity.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    CourseResource addResource = new CourseResource();
                    addResource.ResourceTitle = newResource.ResourceTitle;
                    addResource.CourseID      = newResource.CourseID;
                    var course = await courseDbContext.Courses.SingleOrDefaultAsync(m => m.ID == addResource.CourseID);

                    addResource.CourseName   = course.CourseCode + " - " + course.CourseSemester + " " + course.CourseYear;
                    addResource.ResourceLink = String.Empty;
                    await courseResourceDbContext.Resources.AddAsync(addResource);

                    await courseResourceDbContext.SaveChangesAsync();

                    return(RedirectToPage("/UploadResourceAttachmentPage"));
                }
                else
                {
                    return(Page());
                }
            }
            else
            {
                return(RedirectToPage("/Error"));
            }
        }
Esempio n. 2
0
        public CourseResource Save(CourseResource item)
        {
            this.dbContext.CourseResources.Add(item);
            this.dbContext.SaveChanges();

            return(item);
        }
 public UploadResourceAttachmentPageModel(CourseResourceDbContext adb, ProfileDbContext pDbContext)
 {
     courseResourceDbContext = adb;
     CurrentResource         = new CourseResource();
     CurrentResource         = adb.Resources.Last();
     profileDbContext        = pDbContext;
     CurrentProfile          = new Profile();
 }
Esempio n. 4
0
        public async Task CreateCourseResource(string lectureId, string resourceId, CancellationToken token)
        {
            var moduleIdCourseId = await _repo.GetLectureModuleIdAndCourseId(lectureId, token);

            var courseResource = new CourseResource(moduleIdCourseId.CourseId, moduleIdCourseId.ModuleId, lectureId,
                                                    resourceId);

            await _repo.AddCourseResource(courseResource, token);
        }
Esempio n. 5
0
        public void ConstructorWithCourseIdModuleIdLectureIdResourceId_WhenCalled_SetRequiredPropertiesCorrectly()
        {
            _sut = new CourseResource("courseId", "moduleId", "lectureId", "resourceId");

            Assert.That(_sut.CourseId, Is.EqualTo("courseId"));
            Assert.That(_sut.ModuleId, Is.EqualTo("moduleId"));
            Assert.That(_sut.LectureId, Is.EqualTo("lectureId"));
            Assert.That(_sut.ResourceId, Is.EqualTo("resourceId"));
        }
Esempio n. 6
0
        public AddNewResourceModel(CourseResourceDbContext adb, CourseDbContext cdb, ProfileDbContext pdb)
        {
            courseResourceDbContext = adb;
            courseDbContext         = cdb;

            CoursesList = new List <Course>();
            newResource = new CourseResource();

            profileDbContext = pdb;
            CurrentProfile   = new Profile();
        }
        public async Task <IActionResult> Create([FromBody] CourseResource model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Course course         = _mapper.Map <CourseResource, Course>(model);
            var    courseResponse = await _courseService.CreateAsync(course);

            if (!courseResponse.Success)
            {
                return(BadRequest(courseResponse.Message));
            }

            return(Ok(courseResponse.Extra));
        }
Esempio n. 8
0
 public async Task AddCourseResource(CourseResource courseResource, CancellationToken token)
 {
     await _context.CourseResources.AddAsync(courseResource, token);
 }
Esempio n. 9
0
 public CourseResource Update(int id, CourseResource item)
 {
     throw new NotImplementedException();
 }