public async Task <IActionResult> PutCourseState([FromRoute] int id, [FromBody] CourseState courseState) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != courseState.ID) { return(BadRequest()); } _context.Entry(courseState).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseStateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title")] CourseState courseState) { if (id != courseState.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(courseState); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseStateExists(courseState.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(courseState)); }
public static CourseState ReduceSetActiveRecordsAction(CourseState state, SetActiveRecordsAction action) { if (state.CurrentCourse?.RootRecord != null) { return(new CourseState(state.IsLoading, state.CurrentCourse, state.Commits, GetActiveRecords(state.CurrentCourse.RootRecord, action.ArticleId))); } return(new CourseState(state.IsLoading, state.CurrentCourse, state.Commits, state.ActiveRecords)); }
public async Task <IActionResult> Create([Bind("ID,Title")] CourseState courseState) { if (ModelState.IsValid) { _context.Add(courseState); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(courseState)); }
public async Task <IActionResult> PostCourseState([FromBody] CourseState courseState) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CourseStates.Add(courseState); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCourseState", new { id = courseState.ID }, courseState)); }
public void Seed(ApplicationDbContext dbContext, IServiceProvider serviceProvider) { if (dbContext.CourseStates.Any()) { return; } var course = dbContext.Courses.FirstOrDefault(c => c.Name == "Demo Course"); var courseInstance = new CourseInstance { Course = course, CourseId = course.Id, StartDate = DateTime.UtcNow, EndDate = DateTime.UtcNow.AddMonths(3) }; var userProfile = dbContext.UserProfiles.FirstOrDefault(); var courseState = new CourseState { UserProfile = userProfile, UserProfileId = userProfile.Id, CourseInstance = courseInstance, CourseInstanceId = courseInstance.Id }; var sectionStates = new HashSet <SectionState>(); foreach (var section in course.Sections) { sectionStates.Add(new SectionState { IsComplete = false, CourseState = courseState, CourseStateId = courseState.Id, Section = section, SectionId = section.Id, IsLocked = true, }); } courseState.SectionStates = sectionStates; userProfile.CourseStates.Add(courseState); courseInstance.UserProfiles.Add(userProfile); dbContext.CourseStates.Add(courseState); }
public bool SetCourseState(int course, int studentId, CourseState newStateOfCourse) { //TODO : get courseevent from db and update status return(false); }
public static CourseState ReduceFetchCourseHistoryResultAction(CourseState state, FetchCourseHistoryResultAction action) { return(new CourseState(state.IsLoading, state.CurrentCourse, action.Commits, state.ActiveRecords)); }
public static CourseState ReduceSetCourseAction(CourseState state, SetCourseAction action) { return(new CourseState(false, action.Course, state.Commits, null)); }
public static CourseState ReduceFetchCourseAction(CourseState state, FetchCourseAction action) => new CourseState(true, state.CurrentCourse, state.Commits, state.ActiveRecords);