public async Task <IActionResult> Edit(DefaultModel model, ModCourseEntity item) { ViewBag.Title = "Cập nhật thông tin"; var subjectdata = _subjectService.Find(true, o => o.IsActive).OrderBy(o => o.Name).ToList(); ViewBag.SubjectData = subjectdata; var gradedata = _gradeService.Find(true, o => o.IsActive).OrderBy(o => o.Name).ToList(); ViewBag.GradeData = gradedata; var programdata = _programService.Find(true, o => o.CreateUser == _currentUser.ID).OrderBy(o => o.Name).ToList(); ViewBag.ProgramData = programdata; if (string.IsNullOrEmpty(model.ID) && string.IsNullOrEmpty(item.ID)) { SetMessageWarning("Chưa chọn đối tượng chỉnh sửa"); } else { string ID = !string.IsNullOrEmpty(model.ID) ? model.ID : item.ID; var _item = _service.GetByID(ID); if (string.IsNullOrEmpty(item.Name)) { _item.Name = item.Name; } _item.Description = item.Description; _item.Updated = DateTime.Now; _item.GradeID = item.GradeID; _item.SubjectID = item.SubjectID; _item.ProgramID = item.ProgramID; //TODO: tính toán xem có cần cập nhật lại code ko _item.IsActive = item.IsActive; await _service.AddAsync(_item); ViewBag.Data = _service.GetByID(ID); SetMessageSuccess("Cập nhật thành công"); } ViewBag.Model = model; return(RedirectToAction("index")); }
public ModCourseViewModel(ModCourseEntity item) { this.item = item; }