public async Task <IActionResult> PutListLesson([FromRoute] int id, [FromBody] ListLesson listLesson) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != listLesson.Id) { return(BadRequest()); } _context.Entry(listLesson).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListLessonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,NumberLesson,DayOfWeek,Id_group,Id_teacher,Id_lesson")] ListLesson listLesson) { if (id != listLesson.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(listLesson); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListLessonExists(listLesson.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Id_group"] = new SelectList(_context.Groups, "Id", "Id", listLesson.Id_group); ViewData["Id_lesson"] = new SelectList(_context.Lessons, "Id", "Id", listLesson.Id_lesson); ViewData["Id_teacher"] = new SelectList(_context.Teachers, "Id", "Id", listLesson.Id_teacher); return(View(listLesson)); }
public async Task <IActionResult> PostListLesson([FromBody] ListLesson listLesson) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ListLessons.Add(listLesson); await _context.SaveChangesAsync(); return(CreatedAtAction("GetListLesson", new { id = listLesson.Id }, listLesson)); }
public async Task <IActionResult> Create([Bind("Id,NumberLesson,DayOfWeek,Id_group,Id_teacher,Id_lesson")] ListLesson listLesson) { if (ModelState.IsValid) { _context.Add(listLesson); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Id_group"] = new SelectList(_context.Groups, "Id", "Id", listLesson.Id_group); ViewData["Id_lesson"] = new SelectList(_context.Lessons, "Id", "Id", listLesson.Id_lesson); ViewData["Id_teacher"] = new SelectList(_context.Teachers, "Id", "Id", listLesson.Id_teacher); return(View(listLesson)); }
private async Task ShowListLessonFollowYear(string year, string idTopic) { restLessonService = new RestLessonService(); ListLesson = await restLessonService.GetDataAsync(); // Lấy tất cả các Lesson hiện có if (idTopic == null) { if (year != "All") // Lấy danh sách các Lesson theo năm { ListLesson = ListLesson.Where(c => c.Year.Equals(int.Parse(year))).ToList(); } } else { if (year != "All") // Lấy danh sách các Lesson theo năm { ListLesson = ListLesson.Where(c => c.Year.Equals(int.Parse(year))).ToList(); } // Lấy các Lesson theo Topic chọn ListLesson = ListLesson.Where(c => c.IdTP.Equals(idTopic)).ToList(); } // Download(); }