public ActionResult DeleteHotel(string id) { if (id == null) { return(RedirectToAction("List", "BackendHotel", new { area = "Backend" })); } else { int a; bool check = int.TryParse(id.ToString(), out a); if (check == true) { var result = context.hotels.Find(a); if (result == null) { return(RedirectToAction("List", "BackendHotel", new { area = "Backend" })); } else { client.DeleteHotel_BE(int.Parse(id)); //context.hotels.Remove(result); //context.SaveChanges(); return(RedirectToAction("List", "BackendHotel", new { area = "Backend" })); } } else { return(RedirectToAction("List", "BackendHotel", new { area = "Backend" })); } } }
private void btnXoa_Click(object sender, EventArgs e) { if (id == -1) { MessageBox.Show("Chưa chọn hotel để xoá "); } else { client.DeleteHotel_BE(id); MessageBox.Show("Xoá thành công"); FormHotel_Load(sender, e); ClearTextBox(); } }