public async Task <IHttpActionResult> PutLop(string id, Lop lop) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lop.IdLop) { return(BadRequest()); } db.Entry(lop).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LopExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
//Sự kiên Sửa public void Update(string txtID, string txtName, bool radNam, bool radNu) { try { SinhVien SV = db.SinhVien.FirstOrDefault(n => n.Id == txtID); SV.IdLop = SelectedLop.IdLop; SV.Name = txtName; SV.Sex = radNam ? "Nam" : "Nữ"; SV.Birthday = new DateTime(SelectedYear, SelectedMonth, SelectedDay); db.Entry(SV).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ListSinhVien = new ObservableCollection <SinhVien>(db.SinhVien.ToList()); } catch { MessageBox.Show("Lỗi Sửa Sinh Viên"); SelectedSV = null; } }